02Mar

PHP Delete Files Script

PHP

I needed a script to delete all files inside a folder with certain extension, a script that could be executed with just a click. So here is how i did it:

<?
{
foreach (glob(“*.txt*”) as $fn) {
unlink($fn);
}
}
header(“Location: /1″);
?>

where *.txt is the extension im looking for delete and /1 is the directory inside im placing the script. I saved the above in a file named Delete.php and placed it inside the directory. Then I chmod’ed the entire directory with the following command:

chmod -R /var/www/1

The script works without a flaw.

Share This:
  • StumbleUpon
  • del.icio.us
  • Technorati
  • Reddit
  • Digg
  • Live
  • Google Bookmarks
No comments

Sunday, March 2nd, 2008 at 8:39 pm and is filed under PHP. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a reply