PHPverse 2025

Voting

: one plus zero?
(Example: nine)

The Note You're Voting On

Schraalhans Keukenmeester
18 years ago
Tempting as it may seem to use finfo_file() to validate uploaded image files (Check whether a supposed imagefile really contains an image), the results cannot be trusted. It's not that hard to wrap harmful executable code in a file identified as a GIF for instance.

A better & safer option is to check the result of:

if (!$img = @imagecreatefromgif($uploadedfilename)) {
trigger_error('Not a GIF image!',E_USER_WARNING);
// do necessary stuff
}

<< Back to user notes page

To Top