How do you delete files in a directory. For example I want to delete all files that ARE NOT of the jpg extension.
I used this code but it deleted EVERYTHING!
I used this code but it deleted EVERYTHING!
Code:
$originalfilelist = scandir($memberdir);
foreach($originalfilelist as $files => $values) { chmod($values, 0777 ); if ( (substr($values,-3) !== 'jpg') or (substr($values,-3) !== 'JPG')){ unlink($file.'/'.$values); } }