Drupal 7问题,以编程方式设置用户图片 [英] Drupal 7 issue with programmatically set user picture

查看:180
本文介绍了Drupal 7问题,以编程方式设置用户图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用脚本以Drupal 7中的用户图片进行编程设置。脚本如下所示: Drupal 7以编程方式保存用户图片



脚本工作正常,但一旦为特定用户设置了用户图片,我尝试删除该图片(作为管理员或用户自己),服务器返回:


警告:unlink(/ home / hkdepot /public_html/drupal_dev_4/sites/default/files/avatars/upload/b8f1e69e83aa12cdd3d2babfbcd1fe27_101.jpg):drupal_unlink()中的权限(/home/hkdepot/public_html/drupal_dev_4/includes/file.inc的第2199行)。


该文件不会从文件夹中删除。



这是我应该担心什么?设置图片时是否正确的问题?如何处理?

解决方案


775 = rwxrwxr-x = / strong>:读写执行; 读写执行; 世界阅读,执行


这只是意味着尝试删除文件(可能是www-data)不是所有者,也不在所有权组中。所以你需要


  1. 将文件权限设置为 777

  2. 将所有者更改为正在删除的用户

  3. 将要删除的用户添加到组

进一步阅读:




  • Linux文件许可位图

  • 如何在Linux中更改文件的所有者和组


    • 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?

      解决方案

      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:

      这篇关于Drupal 7问题,以编程方式设置用户图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆