Max Tamer-Mahoney
Max Tamer-Mahoney

Reputation: 11

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

I've Googled around a bit, and can't find any answer that works for me. I'm trying to unlink a file, but nothing happens and no errors appear (display_errors() stopped the page from loading). The code is below. Thanks!

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

Edit: I know the chdir isn't needed, that's just for the later parts in the file.

Upvotes: 1

Views: 145

Answers (1)

Alnitak
Alnitak

Reputation: 340055

You can only delete a file if you also have write permission on the directory containing it.

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

Upvotes: 4

Related Questions