From: Janusz Dobrowolski Date: Wed, 3 Aug 2011 11:22:54 +0000 (+0200) Subject: Added support for png and gif item images. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=93146016e304b50149b7caa2e430bba633aa00de;p=textcart.git Added support for png and gif item images. --- diff --git a/company/0/images/102.jpg b/company/0/images/102.jpg index 479662e..a7cfb14 100644 Binary files a/company/0/images/102.jpg and b/company/0/images/102.jpg differ diff --git a/inventory/manage/items.php b/inventory/manage/items.php index b270f91..b214b7d 100644 --- a/inventory/manage/items.php +++ b/inventory/manage/items.php @@ -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);