Every time I try to write an image using imagejpeg(), I get the following error:
Warning: imagejpeg() [function.imagejpeg]: Unable to open '/home/userdir/public_html/files/images/thumbs/
I’ve checked and this dir has 777 permissions, so it should be able to write to it.
Stranger still, the destination file path being given to imagejpeg() is actually:
/home/userdir/public_html/files/images/thumbs/small/1113/XM324980.jpg
I’ve checked, and permissions are set to 777 all the way. The file doesn’t already exist.
Why would it be having trouble opening the “thumbs” dir to write to the thumbs/small/1113/ dir?
The
imagejpeg()will only create the image in the destination directory but you have used another two sub-directories that issmall/1113for creating the directories you have to use themkdirfunctionality. Please make sure you have created that first and then create the images inside it.