See also: Heapify

Go back to post Create new comment

RSS Be notified of new comments on this post with the RSS feed for this post.

#

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

You can use a restricted version of markdown formatting here. You can use the toolbar above the text field to make this more painless. For more information about markdown please refer to the markdown cheatsheet.

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

A preview of your comment:

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