issue error if file drop on drop area is > maxfilesize

This commit is contained in:
Uwe Steinmann 2024-10-02 14:58:43 +02:00
parent 12fc5c1185
commit ccab32bb42
2 changed files with 28 additions and 0 deletions

View File

@ -1518,6 +1518,7 @@ function getOverallStatusIcon($status) { /* {{{ */
} /* }}} */
function printFileChooserJs() { /* {{{ */
$maxfilesize = $this->getParam('maxfilesize');
?>
$(document).ready(function() {
/* Triggered after the file has been selected */
@ -1525,6 +1526,19 @@ $(document).ready(function() {
var input = $(this),
numFiles = input.get(0).files ? input.get(0).files.length : 1,
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
<?php if($maxfilesize): ?>
if(input.get(0).files[0].size > <?= $maxfilesize ?>) {
noty({
text: "<?= getMLText('uploading_maxsize') ?>",
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
timeout: 1500,
});
return;
}
<?php endif; ?>
input.trigger('fileselect', [numFiles, label]);
});

View File

@ -1510,6 +1510,7 @@ function getOverallStatusIcon($status) { /* {{{ */
} /* }}} */
function printFileChooserJs() { /* {{{ */
$maxfilesize = $this->getParam('maxfilesize');
?>
$(document).ready(function() {
/* do not use bootstrap4 custom form element because it is difficult to localize
@ -1525,6 +1526,19 @@ $(document).ready(function() {
var input = $(this),
numFiles = input.get(0).files ? input.get(0).files.length : 1,
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
<?php if($maxfilesize): ?>
if(input.get(0).files[0].size > <?= $maxfilesize ?>) {
noty({
text: "<?= getMLText('uploading_maxsize') ?>",
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
timeout: 1500,
});
return;
}
<?php endif; ?>
input.trigger('fileselect', [numFiles, label]);
});