imagecreatefromjpeg and PHP 4.4.1

GD and GD2 are useful libraries for creating graphics on-the-fly. Discuss your PHP GD and GD2 scripts here.

Moderators: onion2k, General Moderators

Post Reply
MPT
Forum Newbie
Posts: 3
Joined: Fri Nov 17, 2006 5:23 am

imagecreatefromjpeg and PHP 4.4.1

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If you remove the "@" operator, does it shed more light by way of an error?
MPT
Forum Newbie
Posts: 3
Joined: Fri Nov 17, 2006 5:23 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
MPT
Forum Newbie
Posts: 3
Joined: Fri Nov 17, 2006 5:23 am

Post by MPT »

I wasn't using $_FILES but by modifying the < form> heading and using that I have got it to work - thanks.
Post Reply