Page 1 of 1

[SOLVED] imagecreatefromjpeg related problem

Posted: Thu May 24, 2007 11:30 am
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.

Posted: Thu May 24, 2007 12:21 pm
by volka
You move the file from a to b and then try to open a

Posted: Fri May 25, 2007 4:46 am
by mikeeeeeeey
ahhh makes a lot of sense when you put it like that volka.

thanks a lot! :D