Closed Thread Icon

Topic awaiting preservation: Deleting Files (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=12233" title="Pages that link to Topic awaiting preservation: Deleting Files (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Deleting Files <span class="small">(Page 1 of 1)</span>\

 
Wakkos
Maniac (V) Mad Scientist

From: Azylum's Secret Lab
Insane since: Oct 2000

posted posted 05-25-2002 22:33

I want to delete all the files into a folder, Weadz gave me a little script that I didn't test because i lost my HD, so i was trying with:

code:
<? // 
$p = "/usr/www/htdocs/artreves/robadas/temp";
$d = opendir($p);
while($f = readdir($d))
{
if($f <> "." and $f <> ".."){
unlink("$f");
}
}

?>



Which repeats the same messase as many times as files in the dir:

code:
Warning: Unlink failed (No such file or directory) in /usr/www/htdocs/artreves/deletetemp.php on line 11



And If i print $f instead of 'unlink' it shous the filename.....

Any ideas or other way to do it?

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 05-25-2002 23:15

I'm not positive, but it could be a permissions problem. Check the CHMOD on the file that you are trying to delete the files from.

-Butcher-

Wakkos
Maniac (V) Mad Scientist

From: Azylum's Secret Lab
Insane since: Oct 2000

posted posted 05-26-2002 07:52

Even with permissions ok.........



[This message has been edited by Wakkos (edited 05-26-2002).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-26-2002 09:09

You need to pass full path to the unlink() function, because your PHP script is not located in the same folder as files that you want to delete.

<?

$p = "/usr/www/htdocs/artreves/robadas/temp";
$d = opendir($p);
while ($f = readdir($d))
{
&nbsp;&nbsp;if ($f <> "." and $f <> "..")
&nbsp;&nbsp;{
&nbsp;&nbsp;unlink("$p/$f");
&nbsp;&nbsp;}
}

?>


Wakkos
Maniac (V) Mad Scientist

From: Azylum's Secret Lab
Insane since: Oct 2000

posted posted 05-26-2002 09:27

Weeeeeeee!
it works now!!!
Thanks again mr.maX

« BackwardsOnwards »

Show Forum Drop Down Menu