added fileTooBig alert to drop handler. fixes #578
This commit is contained in:
parent
1366f0b68e
commit
3de760db12
|
@ -1,3 +1,6 @@
|
||||||
|
/* global MAXFILESIZE */
|
||||||
|
const { bytes } = require('./utils');
|
||||||
|
|
||||||
export default function(state, emitter) {
|
export default function(state, emitter) {
|
||||||
emitter.on('DOMContentLoaded', () => {
|
emitter.on('DOMContentLoaded', () => {
|
||||||
document.body.addEventListener('dragover', event => {
|
document.body.addEventListener('dragover', event => {
|
||||||
|
@ -13,10 +16,19 @@ export default function(state, emitter) {
|
||||||
if (target.files.length === 0) {
|
if (target.files.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target.files.length > 1 || target.files[0].size === 0) {
|
if (target.files.length > 1) {
|
||||||
return alert(state.translate('uploadPageMultipleFilesAlert'));
|
return alert(state.translate('uploadPageMultipleFilesAlert'));
|
||||||
}
|
}
|
||||||
const file = target.files[0];
|
const file = target.files[0];
|
||||||
|
if (file.size === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (file.size > MAXFILESIZE) {
|
||||||
|
window.alert(
|
||||||
|
state.translate('fileTooBig', { size: bytes(MAXFILESIZE) })
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
emitter.emit('upload', { file, type: 'drop' });
|
emitter.emit('upload', { file, type: 'drop' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue