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];
if ($file['error'] == 0) {
if($file['error']==1) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_maxsize"));
}
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"));
}
$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"));
}
/* Handle specific error 1 because it happens often */
if($file['error']==1) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_maxsize"));
}
/* All other errors just have a generic message */
if($file['error']!=0) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_failed"));
}
/* Catch uploading files without content */
if ($file["size"]==0) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_zerosize"));
}
/* 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"];
$userfiletype = $file["type"];
$userfilename = $file["name"];
$userfiletmp = $file["tmp_name"];
$userfiletype = $file["type"];
$userfilename = $file["name"];
if($settings->_overrideMimeType) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$tmpfiletype = finfo_file($finfo, $userfiletmp);
if($tmpfiletype != 'application/octet-stream')
$userfiletype = $tmpfiletype;
}
if($settings->_overrideMimeType) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$tmpfiletype = finfo_file($finfo, $userfiletmp);
if($tmpfiletype != 'application/octet-stream')
$userfiletype = $tmpfiletype;
}
/* Check if the uploaded file is identical to last version */