Merge pull request #10010 from atm-john/Fix_cat_photo_upload

Fix event message on upload category picture fail
This commit is contained in:
Laurent Destailleur 2018-11-15 16:43:59 +01:00 committed by GitHub
commit f3228dc4f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -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);
}
}
}

View File

@ -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');