This site is best viewed in Mozilla Firefox or Google Chrome
Fri, 18th May 2012 03:52:30
Never fear, this site is here  

Go back to post Create new comment

#

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
}
?>

Go back to post

Create a new comment

Go to the top
For post: Super simple (common) php hax for dummies.
Your name:
Your email (optional):
Your website (optional):
 
 
 

A preview of your comment:

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