Jr- Posted February 7, 2007 Share Posted February 7, 2007 Ok, I keep trying this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <? $myImage = "test.jpg"; function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth, $quality = 100) { # function should be called createJpegThumbnail(); # $quality = 100 is maximum quality # file size will come down for lower quality level $srcImg = imagecreatefromjpeg("$imageDirectory/$imageName"); $thumbHeight = ($origHeight = imagesy($srcImg)) * ($thumbWidth / ($origWidth = imagesx($srcImg))); $thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight); imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $origWidth, $origHeight); imagejpeg($thumbImg, "$thumbDirectory/$imageName", $quality); imagedestroy($srcImg); imagedestroy($thumbImg); } createThumbnail("image", $myImage, "image", 50); ?> </body> </html> ...and I keep getting this error: Warning: imagejpeg(): Unable to open 'image/test.jpg' for writing in /myDir/uploadTest_2.php on line 25 Does anyone know why it keeps erroring out on the imagejpeg() function? Any help is much appreciated. Thanks, Jr- Link to comment https://forums.phpfreaks.com/topic/37496-image-thumbnail-help/ Share on other sites More sharing options...
Balmung-San Posted February 7, 2007 Share Posted February 7, 2007 Either image/test.jpg does not exist, or the user context that the webserver is running under doesn't have write permissions on the file. Link to comment https://forums.phpfreaks.com/topic/37496-image-thumbnail-help/#findComment-179321 Share on other sites More sharing options...
Jr- Posted February 7, 2007 Author Share Posted February 7, 2007 Well, the directory has write permission allowed on it and the image is in the directory. Is there anything else it could be? Link to comment https://forums.phpfreaks.com/topic/37496-image-thumbnail-help/#findComment-179322 Share on other sites More sharing options...
The Little Guy Posted February 7, 2007 Share Posted February 7, 2007 This is very similar http://snippets.tzfiles.com/snippet.php?id=5 Link to comment https://forums.phpfreaks.com/topic/37496-image-thumbnail-help/#findComment-179323 Share on other sites More sharing options...
Balmung-San Posted February 7, 2007 Share Posted February 7, 2007 Directory != File Just because the image is in a directory that you have write permissions on, doesn't mean you have write permissions on the file. You need to have write permission on the file itself. Link to comment https://forums.phpfreaks.com/topic/37496-image-thumbnail-help/#findComment-179324 Share on other sites More sharing options...
Jr- Posted February 7, 2007 Author Share Posted February 7, 2007 is there a way to set write permission on upload? Link to comment https://forums.phpfreaks.com/topic/37496-image-thumbnail-help/#findComment-179325 Share on other sites More sharing options...
Balmung-San Posted February 7, 2007 Share Posted February 7, 2007 You would have to change permissions of the file once it's on the server. If you're uploading via FTP make sure that everybody has write permission on the file (or if it's numeric, the last digit must be 6). Usually in FTP (and the *nix world) this is called chmod. Link to comment https://forums.phpfreaks.com/topic/37496-image-thumbnail-help/#findComment-179327 Share on other sites More sharing options...
Jr- Posted February 8, 2007 Author Share Posted February 8, 2007 Is there a way you can "make a thumbnail" so to speak but instead of outputting to the browser actually save the file to the directory as a different name without needing write permission to any of the files? Thanks again for all the help guys. Jr- Link to comment https://forums.phpfreaks.com/topic/37496-image-thumbnail-help/#findComment-179737 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.