I have this code:
@unlink($sMediaDir . $iLastID . '' . '.jpg');
How to delete files regardless their extensions? And make it work also with .png, .bmp etc?
PHP: Delete a file with any extension? is not exactly what I am looking for. Thanks!
I have this code:
@unlink($sMediaDir . $iLastID . '' . '.jpg');
How to delete files regardless their extensions? And make it work also with .png, .bmp etc?
PHP: Delete a file with any extension? is not exactly what I am looking for. Thanks!
You can use glob() to find files to delete them
$files = glob($sMediaDir . $iLastID .'.*'); // Look for all files starting with $iLastId
if( count($files)!==0 ){
// If files are found, loop through the array to delete them:
foreach($files as $k=>$file){
unlink($sMediaDir.$file);
}
}
Im not entirely sure about the value of your variables, but you catch my drift :)