Drupal 7 issue with programmatically set user picture

偶尔善良 提交于 2019-12-25 04:08:58

问题


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

  1. Set the file permissions to 777
  2. Change the owner to the user who is deleteing
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!