note 102565 added to function.unlink
[email protected] Mon, 21 Feb 2011 17:57:34 -0800
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
If you have a problem with unwriteable files test this ;)
Its a bit longer but it works really fine for me :)
<?php
public function delete_folder($tmp_path){
if(!is_writeable($tmp_path) && is_dir($tmp_path)){chmod($tmp_path,0777);}
$handle = opendir($tmp_path);
while($tmp=readdir($handle)){
if($tmp!='..' && $tmp!='.' && $tmp!=''){
if(is_writeable($tmp_path.DS.$tmp) && is_file($tmp_path.DS.$tmp)){
unlink($tmp_path.DS.$tmp);
}elseif(!is_writeable($tmp_path.DS.$tmp) && is_file($tmp_path.DS.$tmp)){
chmod($tmp_path.DS.$tmp,0666);
unlink($tmp_path.DS.$tmp);
}
if(is_writeable($tmp_path.DS.$tmp) && is_dir($tmp_path.DS.$tmp)){
k8c_admin_area_write::k8c_delete_folder($tmp_path.DS.$tmp);
}elseif(!is_writeable($tmp_path.DS.$tmp) && is_dir($tmp_path.DS.$tmp)){
chmod($tmp_path.DS.$tmp,0777);
delete_folder($tmp_path.DS.$tmp);
}
}
}
closedir($handle);
rmdir($tmp_path);
if(!is_dir($tmp_path)){return true;}
else{return false;}
}
?>
----
Server IP: 85.214.154.209
Probable Submitter: 77.22.31.182
----
Manual Page -- http://www.php.net/manual/en/function.unlink.php
Edit -- https://master.php.net/note/edit/102565
Del: integrated -- https://master.php.net/note/delete/102565/integrated
Del: useless -- https://master.php.net/note/delete/102565/useless
Del: bad code -- https://master.php.net/note/delete/102565/bad+code
Del: spam -- https://master.php.net/note/delete/102565/spam
Del: non-english -- https://master.php.net/note/delete/102565/non-english
Del: in docs -- https://master.php.net/note/delete/102565/in+docs
Del: other reasons-- https://master.php.net/note/delete/102565
Reject -- https://master.php.net/note/reject/102565
Search -- https://master.php.net/manage/user-notes.php