Added support for png and gif item images.
authorJanusz Dobrowolski <janusz@frontaccouting.eu>
Wed, 3 Aug 2011 11:22:54 +0000 (13:22 +0200)
committerJanusz Dobrowolski <janusz@frontaccouting.eu>
Wed, 3 Aug 2011 11:22:54 +0000 (13:22 +0200)
company/0/images/102.jpg
inventory/manage/items.php

index 479662ea79efd5d880d04faf4948af4ddf2d2c9c..a7cfb140bc033ba4350a33e5d135be4b21edce88 100644 (file)
Binary files a/company/0/images/102.jpg and b/company/0/images/102.jpg differ
index b270f918ab05d1958d3ff85d5db836986d357af3..b214b7d8a88ca4649a7e6ad95a753cf139c25d4c 100644 (file)
@@ -63,10 +63,16 @@ if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
        }       
        $filename .= "/".item_img_name($stock_id).".jpg";
        
-        //But check for the worst 
-       if (strtoupper(substr(trim($_FILES['pic']['name']), strlen($_FILES['pic']['name']) - 3)) != 'JPG')
+       //But check for the worst 
+       $imagetype = exif_imagetype($_FILES['pic']['tmp_name']);
+       if ($imagetype != IMAGETYPE_GIF && $imagetype != IMAGETYPE_JPEG && $imagetype != IMAGETYPE_PNG)
+       {       //File type Check
+               display_warning( _('Only graphics files can be uploaded'));
+               $upload_file ='No';
+       }       
+       elseif (strtoupper(substr(trim($_FILES['pic']['name']), in_array(strlen($_FILES['pic']['name']) - 3)), array('JPG','PNG','GIF')))
        {
-               display_warning(_('Only jpg files are supported - a file extension of .jpg is expected'));
+               display_warning(_('Only graphics files are supported - a file extension of .jpg, .png or .gif is expected'));
                $upload_file ='No';
        } 
        elseif ( $_FILES['pic']['size'] > ($max_image_size * 1024)) 
@@ -74,11 +80,6 @@ if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
                display_warning(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $max_image_size);
                $upload_file ='No';
        } 
-       elseif ( $_FILES['pic']['type'] == "text/plain" ) 
-       {  //File type Check
-               display_warning( _('Only graphics files can be uploaded'));
-               $upload_file ='No';
-       } 
        elseif (file_exists($filename))
        {
                $result = unlink($filename);