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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.