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... Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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 !!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.