fix checking upload error

This commit is contained in:
Uwe Steinmann 2023-08-30 15:48:34 +02:00
parent b3b5d11642
commit 5567b57853

View File

@ -136,31 +136,33 @@ if(!$file_ary) {
} }
$file = $file_ary[0]; $file = $file_ary[0];
if ($file['error'] == 0) { /* Handle specific error 1 because it happens often */
if($file['error']==1) { if($file['error']==1) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_maxsize")); UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_maxsize"));
} }
if($file['error']!=0) { /* All other errors just have a generic message */
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_failed")); if($file['error']!=0) {
} UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_failed"));
if ($file["size"]==0) { }
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_zerosize")); /* Catch uploading files without content */
} if ($file["size"]==0) {
$maxuploadsize = SeedDMS_Core_File::parse_filesize($settings->_maxUploadSize); UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_zerosize"));
if ($maxuploadsize && $file["size"] > $maxuploadsize) { }
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_maxsize")); /* Check if file size is above configured max upload size */
} $maxuploadsize = SeedDMS_Core_File::parse_filesize($settings->_maxUploadSize);
if ($maxuploadsize && $file["size"] > $maxuploadsize) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_maxsize"));
}
$userfiletmp = $file["tmp_name"]; $userfiletmp = $file["tmp_name"];
$userfiletype = $file["type"]; $userfiletype = $file["type"];
$userfilename = $file["name"]; $userfilename = $file["name"];
if($settings->_overrideMimeType) { if($settings->_overrideMimeType) {
$finfo = finfo_open(FILEINFO_MIME_TYPE); $finfo = finfo_open(FILEINFO_MIME_TYPE);
$tmpfiletype = finfo_file($finfo, $userfiletmp); $tmpfiletype = finfo_file($finfo, $userfiletmp);
if($tmpfiletype != 'application/octet-stream') if($tmpfiletype != 'application/octet-stream')
$userfiletype = $tmpfiletype; $userfiletype = $tmpfiletype;
}
} }
/* Check if the uploaded file is identical to last version */ /* Check if the uploaded file is identical to last version */