我有两个文件: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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!