From fa93d64bac80657f604748a0d73780b9e344480c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 20 Mar 2018 17:59:19 +0100 Subject: [PATCH] * Resources: fixed image upload failed for some browsers (Picture type not supported) caused by reporting application/octet-stream instead of image mime-type --- resources/inc/class.resources_bo.inc.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/resources/inc/class.resources_bo.inc.php b/resources/inc/class.resources_bo.inc.php index 3adf3318a8..c349bb2b4c 100755 --- a/resources/inc/class.resources_bo.inc.php +++ b/resources/inc/class.resources_bo.inc.php @@ -897,8 +897,12 @@ class resources_bo * @param int $resource_id * @return mixed string with msg if somthing went wrong; nothing if all right */ - function save_picture($file,$resouce_id) + function save_picture($file,$resource_id) { + if ($file['type'] == 'application/octet-stream') + { + $file['type'] = Api\MimeMagic::filename2mime($file['name']); + } switch($file['type']) { case 'image/gif': @@ -913,14 +917,14 @@ class resources_bo $src_img = imagecreatefrompng($file['tmp_name']); break; default: - return lang('Picture type is not supported, sorry!'); + return $file['type'].': '.lang('Picture type is not supported, sorry!'); } $tmp_name = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'resources-picture'); imagejpeg($src_img,$tmp_name); imagedestroy($src_img); - Link::attach_file('resources',$resouce_id,array( + Link::attach_file('resources',$resource_id,array( 'tmp_name' => $tmp_name, 'name' => self::PICTURE_NAME, 'type' => 'image/jpeg',