Voting

: six plus one?
(Example: nine)

The Note You're Voting On

stuart at purpletoucan dot com
18 years ago
Thanks to Chris dot Calo for the thumbnail snippet. The file type issue is easily resolved by getting the type from the file with getimagesize, and you can handle unsupported types at that stage too. Thus:

list($img_width,$img_height, $type) = getimagesize($source_file); // Get the original dimentions
if ($type != 1 && $type != 2 && $type != 3 && $type != 15) { die("Your file is not a supported format"); }

...and then later check the type again to open the image correctly:

if ( $type == 1 ) { $img_source = imagecreatefromgif($source_file); }
else if ( $type == 2 ) { $img_source = imagecreatefromjpeg($source_file); }
else if ( $type == 3 ) { $img_source = imagecreatefrompng($source_file); }
else if ( $type == 15 ) { $img_source = imagecreatefromwbmp($source_file); }

<< Back to user notes page

To Top