hellonoko Posted February 23, 2007 Share Posted February 23, 2007 I am trying to make the below image resizing code save to a different directory than the one the .php file is in. I have tried a few things but without success. Any ideas? <?php //Name you want to save your file as $file = 'original.jpg'; $save = 't_'.$file; echo "Creating file: $save"; $size = 0.45; // header('Content-type: image/jpeg') ; list($width, $height) = getimagesize($file) ; $modwidth = $width * $size; $modheight = $height * $size; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; // Here we are saving the .jpg, you can make this gif or png if you want //the file name is set above, and the quality is set to 100% imagejpeg($tn, $save, 100) ; ?> Thanks, Ian Quote Link to comment Share on other sites More sharing options...
mcastles Posted February 24, 2007 Share Posted February 24, 2007 did you try specifying the directory to save in relation to where the php file is? <?php $save = '../../thumbnails/t_'.$file; //back two directories and into the thumbnail directory ?> whats the error that you get? is your new directory chmoded? you might also want to try an absolute path: <?php $save = './thumbnails/t_'.$file; //into thumbnail directory that is located in the root of the website. ?> Quote Link to comment Share on other sites More sharing options...
pkSML Posted February 24, 2007 Share Posted February 24, 2007 This *might* help --> http://en.wikipedia.org/wiki/Path_(computing) You want to use a relative path like mcastles said. If the code is in /resize/ and you want to save thumbs in /resize/thumbs/, then $save = './thumbs/t_'.$file; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.