Forum Moderators: coopster

Message Too Old, No Replies

error in imagejpg function

can't open file to write

         

meingallsphp

3:08 pm on Feb 2, 2007 (gmt 0)

10+ Year Member



I am trying to write a .jpg file in one of my scripts, and I am getting the following message:

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'photos/117/11705-1.jpg' for writing

I have checked, and the directory photos/117/ exists and has the correct permissions (755). I also have the same code running on a different site, and it works there.

Does anyone have any suggestions about what I might test or look for?

Thanks!

whoisgregg

4:36 pm on Feb 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The directory will need to be writable by the web user, not by the main user account. To accomplish this, just have the web user own the folder. The easiest way I've found to do this is to have the web user make the folder.

if(![url=http://php.net/is_dir]is_dir[/url]('photos/117')){ [url=http://php.net/mkdir]mkdir[/url]('photos/117', 0755); }