PHP Classes

Security with image functions

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in

      PHP Classes blog  >  PHP security exploit ...  >  All threads  >  Security with image functions  >  (Un) Subscribe thread alerts  
Subject:Security with image functions
Summary:Secure your uploads with imagecreatefrom
Date:2007-06-20 09:48:53
Update:2007-06-20 09:54:09

  1. Security with image functions   Reply   Report abuse  
Picture of Peter Peter - 2007-06-20 09:54:09
In my projects I use the imagecreatefrom functions in order to secure the image upload process:

if (function_exists("imagecreatefromgif")) {
switch($image_ext) {
case 'gif' : $im = @imagecreatefromgif($image_path); break;
case 'jpg': $im = @imagecreatefromjpeg($image_path); break;
case 'png': $im = @imagecreatefrompng($image_path); break;
if ($im) { imagedestroy($im); $is_image = true; }
else { $is_image = false; }