Jump to content

create thumbnails after upload


woodplease

Recommended Posts

hey,

 

i have some code that uploads an image to a directory, and then creates a thumbnail of that image and stores that in another directory. The uploading of the file works, however after re-sizing the image, i get an error

"Warning: imagejpeg() [function.imagejpeg]: Unable to open './images/album_thumb/' for writing: No such file or directory in C:\xampp\htdocs\kens\test2.php on line 43".

The directory is there, so i'm not sure why i'm getting the error. Any ideas?

 

$src =  ($target.$name.".jpg"); 
$dest = "./images/album_thumb/";

$img = imagecreatefromjpeg($src);
	    $width = imagesx($img);
	    $height = imagesy($img);
		$thumbWidth = 10;
	    $new_width = $thumbWidth;
	    $new_height = floor($height * ($thumbWidth / $width));
	    $tmp_img = imagecreatetruecolor($new_width, $new_height);
	    imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
	    imagejpeg($tmp_img, $dest);
      	    imagedestroy($tmp_img);
	    imagedestroy($img);

 

$target is the the location of the file from the upload part of the script, and $name is the name of the file

Link to comment
https://forums.phpfreaks.com/topic/263850-create-thumbnails-after-upload/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.