Adapted system feedback when uploading too large documents

. Added clientside check to avoid uploads > 8MB size
. Adapted message returned by server, when max upload size is exceeded
This commit is contained in:
Cris
2022-02-23 12:57:58 +01:00
parent 78d863a383
commit 2d683390ae
4 changed files with 63 additions and 2 deletions
@@ -119,7 +119,7 @@ class requestAnrechnung extends Auth_Controller
// Validate data // Validate data
if (empty($_FILES['uploadfile']['name'])) if (empty($_FILES['uploadfile']['name']))
{ {
return $this->outputJsonError($this->p->t('ui', 'errorUploadFehlt')); return $this->outputJsonError($this->p->t('ui', 'errorUploadFehltOderZuGross'));
} }
if (isEmptyString($begruendung_id) || if (isEmptyString($begruendung_id) ||
@@ -26,7 +26,8 @@ $this->load->view(
'neu', 'neu',
'maxZeichen', 'maxZeichen',
'errorBestaetigungFehlt', 'errorBestaetigungFehlt',
'systemfehler' 'systemfehler',
'errorDokumentZuGross'
), ),
'anrechnung' => array( 'anrechnung' => array(
'deadlineUeberschritten', 'deadlineUeberschritten',
@@ -26,6 +26,12 @@ $(function(){
// Avoid form redirecting automatically // Avoid form redirecting automatically
e.preventDefault(); e.preventDefault();
var fileInput = $('#requestAnrechnung-uploadfile');
if (!requestAnrechnung.fileSizeOk(fileInput, 8000000)) // 8MB in byte
{
return FHC_DialogLib.alertWarning(FHC_PhrasesLib.t("ui", "errorDokumentZuGross"));
}
FHC_AjaxClient.ajaxCallPost( FHC_AjaxClient.ajaxCallPost(
FHC_JS_DATA_STORAGE_OBJECT.called_path + "/apply", FHC_JS_DATA_STORAGE_OBJECT.called_path + "/apply",
{ {
@@ -161,5 +167,19 @@ var requestAnrechnung = {
// Disable all form elements // Disable all form elements
$("#requestAnrechnung-form :input").prop("disabled", true); $("#requestAnrechnung-form :input").prop("disabled", true);
},
fileSizeOk: function(fileInput, maxSize){
if (fileInput.get(0).files.length){
var fileSize = fileInput.get(0).files[0].size; // in bytes
if (fileSize > maxSize)
{
return false;
}
return true;
}
} }
} }
+40
View File
@@ -12333,6 +12333,46 @@ array(
) )
) )
), ),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'errorDokumentZuGross',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => "Dokument zu groß",
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => "Document maximum size exceeded",
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'errorUploadFehltOderZuGross',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => "Dokument fehlt oder zu groß",
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => "Document missing or maximum size exceeded",
'description' => '',
'insertvon' => 'system'
)
)
),
array( array(
'app' => 'core', 'app' => 'core',
'category' => 'ui', 'category' => 'ui',