Reputation: 1976
I'm having some trouble with the unlink
function.
I use this to create my directory:
$customer_path_files = $_SERVER['DOCUMENT_ROOT']. '/'.$job.'/';
if (!file_exists($customer_path_files)) {
@mkdir($customer_path_files ,0777,true);
}
This works great. The problem is when I try to delete the exact same folder using unlink
. It says that I don't have permissions to do so.
public function deleteFolders($path) {
$result = FALSE;
if(file_exists($path)) {
$result = unlink($path);
} else {
$result = true;
}
return $result;
}
Which is the code I'm using to delete the folders and all subfolders but doesn't work. Now, when I create folders manually, unlink
works perfect under every condition.
I'm running on XAMPP in Windows 8.
Any thoughts?
Upvotes: 0
Views: 56
Reputation: 10061
unlink()
will remove a file.
If you want to remove a directory, you will need to use rmdir()
if (!is_dir('examples')) {
mkdir('examples');
}
rmdir('examples');
Upvotes: 1