powaz Posted July 8, 2007 Share Posted July 8, 2007 hi i need help with unlink(); I need to delete my .jpg files from folder and i'm using: " unlink('files/'.$foto); " as i understand unlink() removes only link but not delete my file ?! so i need to delete my pictures.jpg files from folder... Please help me... Link to comment https://forums.phpfreaks.com/topic/58958-help-with-unlink/ Share on other sites More sharing options...
OLG Posted July 8, 2007 Share Posted July 8, 2007 PHP.net Manual unlink — Deletes a file If i understand you correctly you wanted to delete all of your pictures under a certain directory? This will remove all files under the directory and additionally remove the directory if you so require function SureRemoveDir($dir, $DeleteMe) { if(!$dh = @opendir($dir)) return; while (($obj = readdir($dh))) { if($obj=='.' || $obj=='..') continue; if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, true); } if ($DeleteMe){ closedir($dh); @rmdir($dir); } } //SureRemoveDir('pathtodirectory', false); //false indicates that you do not want to delete the directory as well If your after just 1 file? Then the method you used should work. Link to comment https://forums.phpfreaks.com/topic/58958-help-with-unlink/#findComment-292557 Share on other sites More sharing options...
powaz Posted July 8, 2007 Author Share Posted July 8, 2007 no, i need delete files witch user wants to delete ... in folder files Link to comment https://forums.phpfreaks.com/topic/58958-help-with-unlink/#findComment-292561 Share on other sites More sharing options...
powaz Posted July 8, 2007 Author Share Posted July 8, 2007 maybe i need to close fail like this ?! $fh = fopen('file/'.$foto, 'w') or die("can't open file"); fclose($fh); but it's not working .... or i need to create form to next page, because this file i use in my screen ant it didn't closed?! Whats the problem !!!! Link to comment https://forums.phpfreaks.com/topic/58958-help-with-unlink/#findComment-292585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.