Page 1 of 1

imagecreatefromjpeg and PHP 4.4.1

Posted: Fri Nov 17, 2006 5:33 am
by MPT
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Is there a particular problem with imagecreatefromjpeg and PHP 4.4.1?

I have some code which works fine under Apache on my computer. When I download it to the web space the call fails.

I have used phpinfo and it tells me that GD is active, that JPEGs are enabled and that allow_url_fopen is On (the code is resizing an image from a local machine).

Is there some other thing that I am missing. I have searched the internet and it does mention some problems with 4.4.1 and changes to the imagejpg call (to do with fille security) but as this is reading a file and not writing one I can not see this being the problem.

Code: Select all

$im = @imagecreatefromjpeg($tempfile);
if (!$im)
{
      $attachOK = FALSE; // This is being called.
}

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Fri Nov 17, 2006 12:18 pm
by feyd
If you remove the "@" operator, does it shed more light by way of an error?

Posted: Tue Nov 21, 2006 3:30 am
by MPT
Hi feyd - sorry for the delay in responding to you.

I did not know that removing @ would display an error - thanks for that.

The error I get is

Warning imagecreatefromjpeg(C:\\Documents and Settings\\MPT\\My Documents\\My Pictures\\002_2A.jpg) failed to open stream. No such file or directory

I know the file exists because the file path is created via a form Browse button.

Posted: Tue Nov 21, 2006 6:59 am
by feyd
That's not a proper location most often for PHP however.

How is $tempfile set?

Most often, you'll want to use $_FILES['yourFileFieldName']['tmpname']. .. And because some browsers send the full path in ['name'] you need a basename() call for that.

Posted: Wed Nov 22, 2006 4:20 am
by MPT
I wasn't using $_FILES but by modifying the < form> heading and using that I have got it to work - thanks.