PHP 8.5.0 Alpha 4 available for testing

Voting

: five plus four?
(Example: nine)

The Note You're Voting On

gotdalife at gmail dot com
16 years ago
To anyone who's had a problem with the permissions denied error, it's sometimes caused when you try to delete a file that's in a folder higher in the hierarchy to your working directory (i.e. when trying to delete a path that starts with "../").

So to work around this problem, you can use chdir() to change the working directory to the folder where the file you want to unlink is located.

<?php
$old
= getcwd(); // Save the current directory
chdir($path_to_file);
unlink($filename);
chdir($old); // Restore the old working directory
?>

<< Back to user notes page

To Top