PHP 与权限
我有一个应用程序正在传输到新服务器。这样做时,客户帐户的上传功能停止工作,因为文件夹的所有者是“ftp”而不是“apache”,我通过重命名文件夹,然后使用我从某处复制并粘贴到的目录复制功能解决了这个问题。具有正确名称的新文件夹,之后一切都很酷。
我的问题是,php 可以更改文件夹或文件的所有权吗?
I have an application that I am transferring to a new server. In doing so the upload feature for customers accounts stopped working because the owner of the folders was 'ftp' and not 'apache' I solved it by renaming the folder and then using a directory copy function that I copied and pasted from somewhere in to a new folder with the correct name and it was all cool after that.
My question is this, can php change the ownership of a folder or files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,php 可以更改文件的所有权。使用
chown($file, $user)
。您可以编写一个简单的递归脚本来使用 chown 更改每个文件的所有者。Yeah, php can change ownership of a file. Use
chown($file, $user)
. You could write a simple recursive script to change owner for each file using chown.是的,只要运行该程序的用户有权执行此操作。
您可以使用chown 函数或将 shell 命令包装在 exec 调用中以递归方式执行,无需像下面那样进行编程
Yes, as far as the user under which it runs has the permissions to do that.
You could use the chown function or wrap the shell command in an exec call to do it recursively with no need to program that as in