Skip to content

Commit

Permalink
Fix envent message on upload category picture
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-john committed Nov 13, 2018
1 parent 9447e66 commit c6cf748
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion htdocs/categories/photos.php
Expand Up @@ -69,7 +69,24 @@
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);
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/html.formfile.class.php
Expand Up @@ -1635,7 +1635,7 @@ function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $for
*/
private function _formAjaxFileUpload($object)
{
global $langs;
global $langs, $conf;

// PHP post_max_size
$post_max_size = ini_get('post_max_size');
Expand Down

0 comments on commit c6cf748

Please sign in to comment.