Home  >  Article  >  Backend Development  >  上传目录没有写权限

上传目录没有写权限

WBOY
WBOYOriginal
2016-06-23 13:57:323632browse

我用一个插件发布新闻,在本地上传图片是可以的,但挂到服务器就不行了,提示上传目录没有写权限。


回复讨论(解决方案)

那就改下权限就是了。

chmod -R 755 path

出现这种情况是因为apache的用户www-data对文件夹没有写权限,可以用以下语句查看拥有者与组用户是谁,并查看权限。

<?php$folder=上传的文件目录;$owner = posix_getpwuid(fileowner($folder));$group = posix_getpwuid(filegroup($folder));echo 'owner:'.$owner['name'].'<br>';echo 'group:'.$group['name'].'<br>';echo 'perms:'.substr(sprintf('%o',fileperms($folder)),-4);?>


如没有权限可以先在linux命令修改,不过可能需要管理员操作
chown www-data:www-data folder // 修改拥有者
chmod 0755 folder                             // 修改权限

恩 linux 服务器对应文件夹没有写权限

楼主,如果你的代码中有对该文件夹的创建,你只需要在创建的时候将权限设置为755

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn