Re: [PHP] How To Delete All Files In A Directory

2002-11-12 Thread @ Edwin
Hello,

"@ Nilaab" <[EMAIL PROTECTED]> wrote:

> Hello Everyone,
>
> I have a directory that I want emptied everytime a script accesses a
certain
> function. I tried using rmdir() and then mkdir(), thinking that it will
> delete the directory and the contents within it, and would create a brand
> new directory for me to work with from scratch. Well, that didn't happen
and
> I read the PHP docs to see why.

I think you already saw the reason why.

  http://us.php.net/manual/en/function.rmdir.php

> I checked to see how else I can do this by reading about some other
> filesystem functions, and now I'm more confused than ever. Which
> combinations of functions would I need to empty a directory's entire
> contents? I just need some direction on this. Thanks.

Maybe you're looking for this:

  http://us.php.net/manual/en/function.unlink.php

You can find more info in the manual:

  http://us.php.net/manual/en/ref.filesystem.php

- E


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] How To Delete All Files In A Directory

2002-11-12 Thread Martin Towell
you could break out into the shell and do
rm $dir/*(rm -r $dir/*  if there's directories too)
 (or  del $dir/*.*  for dos)

or use opendir, readdir, closedir to read the directory's content and use
unlink to delete the file(s)

(if $dir is not hardcoded, I can see a security hole here)

-Original Message-
From: @ Nilaab [mailto:superbus22@;attbi.com]
Sent: Wednesday, November 13, 2002 1:32 PM
To: Php-General
Subject: [PHP] How To Delete All Files In A Directory


Hello Everyone,

I have a directory that I want emptied everytime a script accesses a certain
function. I tried using rmdir() and then mkdir(), thinking that it will
delete the directory and the contents within it, and would create a brand
new directory for me to work with from scratch. Well, that didn't happen and
I read the PHP docs to see why.

I checked to see how else I can do this by reading about some other
filesystem functions, and now I'm more confused than ever. Which
combinations of functions would I need to empty a directory's entire
contents? I just need some direction on this. Thanks.

- Nilaab


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php