Trying to delete a file, but it refuses to be deleted. I’ve tried the following which has if statement that check the file already exists & other .db file is blank. Path is correct, setting it to 666 so can delete, then unlink, then writing the file back with the word “open” in it.
if(file_exists("results_files/linktracker/linktrackerlock.txt") && file_get_contents("results_files/linktracker/linktracker.db") == "") { // check for reset condition, ie. db file wiped
chmod("results_files/linktracker/linktrackerlock.txt", 0666);
unlink("results_files/linktracker/linktrackerlock.txt");
file_put_contents("results_files/linktracker/linktrackerlock.txt", "open");
}
chownwill change the ownership of the file passed as first argument, you are probably better off usingchmod(which is used to change permissions).