Jump to content

[SOLVED] how to empty folder contents


steveh62

Recommended Posts

$dir = 'folder/';
if(!($dir = realpath($dir)))
  die("Folder not found");
foreach(scandir($dir) as $file){
  if($file == '.' || $file == '..') continue;
  $ext = substr($file,0,strrpos($file,'.')+1);
  if($ext == 'jpeg' || $ext == 'jpg'){
    unlink($dir.'/'.$file);
    print "Removed $dir/$file<br>";
  }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.