[英]Nervgh Angular File Upload - How do I restrict the file formats to say jpeg and png?
[英]How i can restrict some file formats to be upload?
我正在使用角度文件上传(nv-file-select)上传文件,现在我的问题是如何限制某些文件格式,以便用户只能看到doc / docx和xls / xlsx格式的文件。
<input type="file" nv-file-select uploader="vm.uploader"
name="uploadFile"
id="file1"
ng-model="vm.fileInfo.filename"
ng-click="vm.onFileClick()" / >
请帮我!
尝试这个
<input type="file" accept=".xls,.xlsx" />
只需尝试添加过滤器:
$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;
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.