问题描述
我有两个文件:b.php 和 test.txt
I have two files: b.php and test.txt
<?php
$b = "test.txt";
unlink($b);
?>
错误是:警告:unlink(test.txt) [function.unlink]: Permission denied
and the error is: Warning: unlink(test.txt) [function.unlink]: Permission denied
为什么?b.php 和 test.txt 是 777 同组/登录
why? b.php and test.txt is 777 and the same group/login
如果我在父目录上设置 777 我可以执行 unlink 但我必须设置 777 并返回到 755?
if I set 777 on the parent directory I can execute unlink but i have to set 777 and back to 755?
推荐答案
您(就像在运行 b.php 的进程中一样,您可以通过 CLI 或网络服务器) 需要对文件所在目录的写访问权限.您正在更新目录内容,因此对该文件的访问权限是不够的.
You (as in the process that runs b.php, either you through CLI or a webserver) need write access to the directory in which the files are located. You are updating the directory content, so access to the file is not enough.
请注意,如果您使用 PHP chmod() 函数将文件或文件夹的模式设置为 777,则应使用 0777以确保该数字被正确解释为八进制数.
Note that if you use the PHP chmod() function to set the mode of a file or folder to 777 you should use 0777 to make sure the number is correctly interpreted as an octal number.
这篇关于权限被拒绝 - php unlink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)