sradha
02-28-2012, 08:25 AM
Hi all,
I am unable to delete a file lying in a particular directory even though the directory is writeable.
I have a folder named 'sample' which contains another sub folder named 'images' and a php file ( the file which contains the code to perform delete operation).
I am using xampp (localhost).It seems the folder path is correct and the folder is writeable too.I could list all the files lying in the directory but I am unable to delete them.
I am getting the following errors,
Warning: unlink(.) [function.unlink]: Permission denied in C:\xampp\htdocs\sample\del_file.php on line 19
..
Warning: chmod() [function.chmod]: No such file or directory in C:\xampp\htdocs\sample\del_file.php on line 16
Warning: unlink(..) [function.unlink]: Permission denied in C:\xampp\htdocs\sample\del_file.php on line 19
apache_pb.gif
Warning: chmod() [function.chmod]: No such file or directory in C:\xampp\htdocs\sample\del_file.php on line 16
Warning: unlink(apache_pb.gif) [function.unlink]: No such file or directory in C:\xampp\htdocs\sample\del_file.php on line 19
Here is my code.
$filename = './images/';
echo realpath($filename);
if (file_exists($filename)) {echo "exists";}else{echo "not exists";}
if (is_writable($filename)) {
echo 'The file is writable';
} else {
echo 'The file is not writable';
}
if ($handle = opendir($filename)) {
while (false !== ($file = readdir($handle))) {
echo $file."<br/>";
//chmod("apache_pb.gif", 0777);
unlink($file);
}
closedir($handle);
}
I am unable to delete a file lying in a particular directory even though the directory is writeable.
I have a folder named 'sample' which contains another sub folder named 'images' and a php file ( the file which contains the code to perform delete operation).
I am using xampp (localhost).It seems the folder path is correct and the folder is writeable too.I could list all the files lying in the directory but I am unable to delete them.
I am getting the following errors,
Warning: unlink(.) [function.unlink]: Permission denied in C:\xampp\htdocs\sample\del_file.php on line 19
..
Warning: chmod() [function.chmod]: No such file or directory in C:\xampp\htdocs\sample\del_file.php on line 16
Warning: unlink(..) [function.unlink]: Permission denied in C:\xampp\htdocs\sample\del_file.php on line 19
apache_pb.gif
Warning: chmod() [function.chmod]: No such file or directory in C:\xampp\htdocs\sample\del_file.php on line 16
Warning: unlink(apache_pb.gif) [function.unlink]: No such file or directory in C:\xampp\htdocs\sample\del_file.php on line 19
Here is my code.
$filename = './images/';
echo realpath($filename);
if (file_exists($filename)) {echo "exists";}else{echo "not exists";}
if (is_writable($filename)) {
echo 'The file is writable';
} else {
echo 'The file is not writable';
}
if ($handle = opendir($filename)) {
while (false !== ($file = readdir($handle))) {
echo $file."<br/>";
//chmod("apache_pb.gif", 0777);
unlink($file);
}
closedir($handle);
}