function.
Aside from checking the suffix, you could just check that a valid image type was supplied.
<?php
// i assume here that the form field name value is "imagefile"
$imagename = basename($_FILES['imagefile']['name']);
$ext = substr($imagename, strrpos($imagename, '.') + 1);
// i hate suppression but you don't seem to mind it
if(@exif_imagetype($_FILES['imagefile']['tmp_name']) !== false)
{
// process it here, its a valid image type, also do other checks
}
else
{
@unlink($_FILES['imagefile']['tmp_name']); // its bad, get rid
}
?>
Aside from checking the suffix, you could just check that a valid image type was supplied.
<?php // i assume here that the form field name value is "imagefile" $imagename = basename($_FILES['imagefile']['name']); $ext = substr($imagename, strrpos($imagename, '.') + 1); // i hate suppression but you don't seem to mind it if(@exif_imagetype($_FILES['imagefile']['tmp_name']) !== false) { // process it here, its a valid image type, also do other checks } else { @unlink($_FILES['imagefile']['tmp_name']); // its bad, get rid } ?>