问题
I am using a script to programmatically set the user picture in Drupal 7. The script is depicted here: Drupal 7 save user picture programmatically.
The script works fine, but once the user picture has been set for a specific user, and if I try to delete that picture (as an admin or as the user himself) the server returns:
Warning: unlink(/home/hkdepot/public_html/drupal_dev_4/sites/default/files/avatars/upload/b8f1e69e83aa12cdd3d2babfbcd1fe27_101.jpg): Permission denied in drupal_unlink() (line 2199 of /home/hkdepot/public_html/drupal_dev_4/includes/file.inc).
The file does not get deleted from the folder.
Is this anything I should worry about? Is that a right's issue when setting the picture? How do I deal with it?
回答1:
775 = rwxrwxr-x = User: Read Write Execute; Group: Read Write Execute; World: Read, Execute
It just means that the user that is trying to delete the file (likely www-data) is not the owner nor is it in the ownership group. So you either need to
- Set the file permissions to
777
- Change the owner to the user who is deleteing
- Add the user who is deleting to the group
Further reading:
- Linux File Permission Bitmask
- How to change a file's owner and group in Linux
来源:https://stackoverflow.com/questions/15336963/drupal-7-issue-with-programmatically-set-user-picture