PHP中的chmod 777 [英] chmod 777 in php

查看:113
本文介绍了PHP中的chmod 777的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用mkdir()在php中创建一个文件夹,则该文件夹具有www-data:www-data用户和755权限.

If I create a folder in php with mkdir() it has the www-data : www-data user and 755 permissions.

问题是我无法使用ftp用户删除此文件夹(zapbe:psasrv) 我试图用php中的chmod($ path,"0777")修改文件夹,但这不起作用.

The problem is I can't delete this folder with the ftp-user (zapbe:psasrv) I tried to modify the folder with chmod($path, "0777") in php but this doesn't work.

如何使www-data和ftp-user可读/可删除创建的文件夹和上载的文件?

How can I make the created folders and uploaded files readable / removeable for both the www-data and the ftp-user?

推荐答案

bool chmod ( string $filename , int $mode )

在PHP中,它们可能会对安全性造成一些限制,因此,取决于您的配置,它可能无法正常工作.

Within PHP they might be some limitations on the security, therefore the depending on your configuration it may not work.

上面的函数返回一个booleon,以通知您它成功更改了实体权限.

The above function returns a booleon to let you know either it has succeed in changing the entities permissions.

if(!chmod($directory,0777))
{
    echo "Unable to chmod $direcotry";
}

还引用了PHP:

当前用户是运行PHP的用户.您可能不是用于普通Shell或FTP访问的用户.在大多数系统上,只有拥有该文件的用户才能更改该模式.

The current user is the user under which PHP runs. It is probably not the same user you use for normal shell or FTP access. The mode can be changed only by user who owns the file on most systems.

了解以上内容后,您应该查看 chown

Understanding above you should look at chown

这篇关于PHP中的chmod 777的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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