dongxiongshi9952 2014-10-12 15:04
浏览 53
已采纳

Ubuntu服务器文件夹权限

I have an uploads directory on my server, php upload works fine when folder's permission is set to 755 but if I make new dir inside uploads (uploads/subuploaddir) upload fails and I need to set 755 permission for this folder manually, so my question is how can I set 755 permission for uploads dir and all of it's future created sub directories?

PS. chmod -R 755 ...mypath/uploads doesn't work

Thanks in advance. All answers are very appreciated. Peter

UPDATE: Problem solved, my fault. PHP creates folders with permission 777 as default and I created folders for testing purposes through FTP manually, so it was created by another system user and with different permission.

  • 写回答

2条回答 默认 最新

  • doufeng3602 2014-10-12 15:13
    关注

    Use

    umask(022);
    

    in PHP before creating a file (e.g. line 1 in index.php). Using that option, every files that PHP creates will have a permission that equals to 755. If that doesn't work, search your code for calls to umask and change them to the one above.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能