There are a couple of ways to go about this.
- Use all PHP functions; more O/S independent:
foreach (glob("path/to/dir/*.jpg") as $filename) {
echo "$filename size " . filesize($filename) . "\n";
unlink("path/to/dir/".$filename);
}
- Use PHP's backticks to execute a system command (WARNING: O/S dependent!):
$unix_command = `rm -f path/to/dir/*.jpg`;
$windows_command = `del /Q path/to/dir/*.jpg`;
$mac_command = die("get a real O/S");
Preferred method would, of course, be #1. Make sure you have proper permissions though!
NOTE: The example provided in solution #1 was copied WITH LITTLE MODIFICATION from a manual page located at PHP.net. Make sure you're checking the manual for any quick-fixes they have listed next time!