diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 472a8eb9b95..1c5359b90e8 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -69,7 +69,24 @@ if ($id > 0) if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->id) { - $object->add_photo($upload_dir, $_FILES['userfile']); + + $file = $_FILES['userfile']; + if (is_array($file['name']) && count($file['name']) > 0) + { + foreach ($file['name'] as $i => $name) + { + if(empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i]) ) + { + setEventMessage($file['name'][$i] .' : '. $langs->trans(empty($file['tmp_name'][$i])? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles' ) ); + unset($file['name'][$i],$file['type'][$i],$file['tmp_name'][$i],$file['error'][$i],$file['size'][$i]); + } + } + } + + if(!empty($file['tmp_name'])){ + $object->add_photo($upload_dir, $file); + } + } } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 4e77269db4c..42854203196 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1635,7 +1635,7 @@ class FormFile */ private function _formAjaxFileUpload($object) { - global $langs; + global $langs, $conf; // PHP post_max_size $post_max_size = ini_get('post_max_size');