Question

I want to delete some files in a directory.So I used unlink() .But it doesn't delete the files in perticular directory.Is this a permission problem ?. If so how to solve that .

     $path_name="/etc/smokeping/devices/".$menu_name1;
        echo $path_name;

        // Delete file off of hard disk using PHP command unlink:
        $do = unlink($path_name);            
        if($do == "1")
            {
                echo "The file was deleted successfully.";
            }
        else
            {
                echo "There was an error trying to delete the file.";
            } 
Was it helpful?

Solution

Your code most likely doesn't run as root and a file in /etc is most likely owned by root. So your PHP script cannot do anything to it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top