[SOLVED] imagecreatefromjpeg related problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mikeeeeeeey
Forum Contributor
Posts: 130
Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK

[SOLVED] imagecreatefromjpeg related problem

Post by mikeeeeeeey »

Hi guys,

I've got a small chunk of script for uploading an image and then creating a thumbnail of this and uploading this too.

Trouble is the both work when on their own, but combine them together and you get the following error:

Code: Select all

Warning: imagecreatefromjpeg(c:/wamp/tmp\php277.tmp) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in C:\wamp\www\stella\admin.php on line 68
which is weird, since the move_uploaded_file function still works. I think it may be something to do with the $_FILES['image']['tmp_name'] getting used, but I could be very wrong.

Here's the code:

Code: Select all

$image = $_FILES['image']['name'];
$tmp = $_FILES['image']['tmp_name'];

$dir = opendir("portfolio/" . $section . "/");
move_uploaded_file($tmp, "portfolio/" . $section . "/" . $image)
	or die("Could not copy: " . $section . "/" . $image);
						
$img = imagecreatefromjpeg($tmp);
$tmp_img = imagecreatetruecolor( 45, 45 );
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, 45, 45, imagesx( $img ), imagesy( $img ));
imagejpeg( $tmp_img, "portfolio/" . $section . "/thumbs/" . $image );
					
closedir( $dir );
Anyone have any ideas?

Thanks a bunch.
Last edited by mikeeeeeeey on Fri May 25, 2007 4:44 am, edited 1 time in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

You move the file from a to b and then try to open a
User avatar
mikeeeeeeey
Forum Contributor
Posts: 130
Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK

Post by mikeeeeeeey »

ahhh makes a lot of sense when you put it like that volka.

thanks a lot! :D
Post Reply