我有写文件的权限,但是我不能使用unlink()& #39;命令用于删除


I have write permissions on a file, but I can't use the "unlink()" function to delete it

我在谷歌上搜索了一下,找不到任何适合我的答案。我试图解除一个文件的链接,但没有发生任何事情,也没有出现错误(display_errors()阻止了页面加载)。代码如下。谢谢!

 chdir("/var/www/lib.techtri.be/");
 unlink("/var/www/lib.techtri.be/R1Count.txt");

编辑:我知道chdir是不需要的,那只是在文件的后面部分。

只有当你对文件所在目录有写权限时,你才能删除文件。

% mkdir foo
% touch foo/bar
% chmod u-w foo
% rm foo/bar
rm foo/bar: Permission denied