I am using w2ui(http://w2ui.com/) plugin. I am using the upload model.
fields: [
{ name: 'taskName', type: 'text', required: true},
{ name: 'taskDomain', type: 'text', required: true},
{ name: 'mailList', type: 'file', accept:'.txt',options: formoptions('you can only upload file that ext txt',['txt']), required: true}
],
function formoptions (placehold,allowExt){
options = {
selected : [], // selected array
placeholder : placehold,
max : 0,
maxSize : 0,
maxFileSize : 0,
maxWidth : 250,
maxHeight : 350,
maxDropHeight : 350,
silent : true,
renderItem : null,
style : '',
onClick : null,
onAdd : function (event){
s =this;
for(var i in event){console.log(i)}
event.onComplete=function (argument) {
if(!isAllowUpload(event.file.name,allowExt)){
//forbidden filetype
w2alert('just allow'+String(allowExt)+'!');
/***the question is here How do I remove this file***/
}
}
},
onRemove : null,
onMouseOver : null,
onMouseOut : null
};
return options;
}
I have some questions about using the w2ui upload model. When users uploads a file, we need to check the file to ensure the file type is permitted. How can I exclude files of a forbidden type?