I am using angular file upload (nv-file-select) to upload file, now my question is how can i restrict some file formats so that user can only see files with doc/docx and xls/xlsx format.
<input type="file" nv-file-select uploader="vm.uploader"
name="uploadFile"
id="file1"
ng-model="vm.fileInfo.filename"
ng-click="vm.onFileClick()" / >
Please help me!
尝试这个
<input type="file" accept=".xls,.xlsx" />
Just try with adding filters:
$scope.vm.uploader.filters.push({
name: 'fileFormatFilter',
fn: function(item, options) {
var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
return '|doc|docx|xls|xlsx|'.indexOf(type) !== -1;
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.