i've been trying to figure out why my Php code is giving me a annoying error. I've tried countless functions from previous post but the error its been giving is "Permission Denied". From my understanding either i have to have special privledges to delete files, etc.. I've tried multiple solutions but I'm still getting this error. If anyone can point me in the right direction, that'll be great. Ive post a snippet of my code below.. Thanksss
$first_sub = "my_dir";
if(is_dir($first_sub)){
$read_sub1 = opendir($first_sub);
while(false !== ($files = readdir($read_sub1))){
if($files!="." && $files!=".."){
unlink($first_sub ."/". $files);
}
}
closedir($read_sub1);
For those who land on this page, it may be as simple as not setting
$files
to an existing file.It is unfortunate, but I found that the message:
Warning: move_uploaded_file(): Unable to move
can also meanfile not found
.Not likely the cause of this OP's problem, but certainly worth verifying the file represented by the variable you pass actually exists in the directory.
You should set proper permission to your server directories: Visit: http://bd1.php.net/chmod
just before
unlink
you can call this function.I got that an error from unlink permission denied. But I fix it. The error displays like this unlink(../foldername/) Permission denied.
My wrong code is like this:
now i fix it my correct code is like this: