Nakor Posted April 30, 2006 Share Posted April 30, 2006 I am looking for a way to delete all of the files in a directory, be it with wildcards or some sort of a function argument that I am not aware of. Any help will be greatly appreciated. Link to comment Share on other sites More sharing options...
calvin182 Posted April 30, 2006 Share Posted April 30, 2006 <?php$dir = "";foreach (glob("$dir/*") as $filename) { echo "$filename - size: " . filesize($filename) . " bytes" . "\n"; unlink($filename);}?> I haven't tested it, this is what I came up with from searching on http://www.php.net but all you should have to do is set the directory and in theory it should work. Link to comment Share on other sites More sharing options...
Nakor Posted April 30, 2006 Author Share Posted April 30, 2006 Ah, yes that would work as well. I just ended up settling with exec("rm -f *.*"); but now that I think about it, your solution would end up being better, as it is probably more platform independent. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now