无法使用 php 复制文件,权限被拒绝 [英] Can't copy file with php, permission denied

查看:69
本文介绍了无法使用 php 复制文件,权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 php 将上传的文件复制到主目录中的文件夹中.我向 Apache 用户 (www-data) 授予了所有权限,但是当我尝试复制它时,我收到警告无法打开流:权限被拒绝".

I'm trying to copy an uploaded file through php to a folder in the home directory. I gave every permission to the Apache user (www-data) but when I'm trying to copy it I get a warning "failed to open stream: Permission denied".

copy("$target_file", "/home/pap-x/meshes/Part_A.dae");

怎么了?

推荐答案

除了 www-data 对 $target 目录具有权限外,它必须至少对 target 之上的每个目录具有执行权限.如果其中任何一个目录拒绝访问,那么 www-data 将无法找到目标目录.

In addition to www-data having permissions to the directory of $target, it must have at least execute permissions to every directory above the target. If any of those directories deny access then www-data will not be able to find the target directory.

这篇关于无法使用 php 复制文件,权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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