I try to upload an image and get the following error:

warning: imagejpeg() [function.imagejpeg]: Unable to open '/filename.jpg' for writing: Permission denied in /home/examplecom/public_html/foldername/includes/image.gd.inc on line 212.

How do I fix it?

thanks,
DP

Comments

cog.rusty’s picture

Check your admin/settings/file-system page. What are your setting for "File system path", "Temporary directory", and "Download method" ?

Check the real "files" and "temp" directories specified there, with your FTP program. They should be:
- either owned by user 'apache' and have permissions 755,
- or owned by your own user account and have permissions 777 (so that apache can write in them).

dailypress’s picture

I made some changes and now get:

* warning: move_uploaded_file(sites/default/files/photos/image_1/display.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/site/public_html/Folder/includes/file.inc on line 572.
* warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/php7ErNZY' to 'sites/default/files/photos/image_1/display.jpg' in /home/Site/public_html/Folder/includes/file.inc on line 572.
* File upload error. Could not move uploaded file.

dailypress’s picture

I changed the permission to 755

Which should I chose? 755 or 777?

and I think I made too much changes: now I get the following error:

# The selected file /var/tmp/file47hbRY could not be copied.
# The selected file /var/tmp/filepQA1Is could not be copied.
# The selected file /var/tmp/file2nqkBW could not be copied.
# The selected file /var/tmp/file3Q5Xtq could not be copied.
# The selected file /var/tmp/fileGZNTmU could not be copied.
# The selected file /var/tmp/fileVwx8fo could not be copied.
# The selected file /var/tmp/fileaF4G9R could not be copied.
# The selected file /var/tmp/filePVDy3l could not be copied.
# The selected file /var/tmp/file0ylIXP could not be copied.
# The selected file /var/tmp/file9Rj8Rj could not be copied.
# The selected file /var/tmp/file83kRMN could not be copied.
# The selected file /var/tmp/file1KgUHh could not be copied.
# The selected file /var/tmp/fileODrgDL could not be copied.

dailypress’s picture

Thanks as always... I spent the whole day and couldnt figure it out. I changed the permission to 755 and it all works now!

:) yeay!!!

dailypress’s picture

So the extracting works for zip folders containing images with only .jpg extensions. The JPG extensions do not extract.
I changed the File uploads and added JPG but it still doesnt work.

DOes it have to do with the Photo Module? And why is it case sensitive?

cog.rusty’s picture

What zip folders? And how are you extracting them?

I don't know what the Photo Module is, but filenames in Unix systems are always case-sensitive (unlike Windows).

dailypress’s picture

I upload and extract images using the Photos Module. It has an option: "Import Zip Folders"
However, it only extracts zip folders when the files in it are "names.jpg" and not "names.JPG"

http://drupal.org/project/photos

cog.rusty’s picture

They should be able to fix the module if you tell them about it.

Until then, you could rename them before putting them in the zip file (at least the files which you upload yourself).

dailypress’s picture

thanks, I did post under the module itself.
Unfortunately I have to rename over 1000 images.

cog.rusty’s picture

Are they in Windows? You can use a cmd console to ren *.JPG *.jpg or, if they are scattered in many subfolders, you can use a utility program such as http://www.den4b.com/downloads.php?project=ReNamer to drag-and-drop them from their top folder or from a search window, and to change their extension with one click.

dailypress’s picture

WOW...youre amazing... thanks for the software!!!!

It worked perfectly fine!! :)

prokopton’s picture

Sub.

prokopton’s picture

Here's what worked for me on Ubuntu 10.04 LTS:

chgrp -R www-data /var/www/files/
chmod -R 775 /var/www/files/

--7(owner) 7 (group) 5 (world) permissions. The www-data group needs read, write and execute permission. Try 777 if it doesn't work.