Wed, 19th Nov 2008 23:36:05
Never fear, this site is here

Back to Super simple (common) php hax for dummies.

Make a new comment

Comments

# Author: mals
Mon, 7th Apr 2008 22:58:44
Your solution wouldn't work due to the undefined
getext()
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
}
?>

Make a new comment

Powered by Debian, Jack Daniels, Guinness, and excessive quantities of caffeine and sugar.