BOX UI Element File Uploader
回答済みHi,
How to validate file format before uploading file using BOX UI Element -Box Content Uploader?
Ref : https://developer.box.com/docs/box-content-uploader
Regards,
VinayV
-
Hi jcleblanc,
But i want to validate the file type before upload complete. i have added a listener 'beforeupload' where i could retrieve the added files before upload, but i was not able to cancel the event in case of invalid file type. Check the code as below.
uploader.on('beforeupload', (data) => {
if (data != undefined) {
var fileName = data[0].name;
var ext = (-1 !== fileName.indexOf('.')) ? fileName.replace(/.*[.]/, '').toLowerCase() : '';
var allowed = ['doc', 'docx', 'xls', 'xlsx', 'pdf'];if (!allowed.length) { return true; }
for (var i = 0; i < allowed.length; i++) {
if (allowed[i].toLowerCase() == ext) { return true; }
}
alert('This file types are not allowed to upload!');
return false;
}
});It would be great if you could help me resolve this issue.
サインインしてコメントを残してください。
コメント
2件のコメント