unlink works great with paths.
Description of bool unlink (string $ filename [, resource $ context])
Deletes the file name. Like Unix C, the unlink () function. Level E_WARNING error will be generated on failure.
file name
Path to the file.
In case of problems with the rights prohibiting the error, this sometimes caused, when you tried to delete the file located in the folder above in the hierarchy, in your working directory (that is, when you try to delete the path starting with "../") .
So, to get around this problem, you can use chdir () to change the working directory to the folder where the file you want to disable is located.
<?php $old = getcwd(); // Save the current directory chdir($path_to_file); unlink($filename); chdir($old); // Restore the old working directory ?>
ayush
source share