Open sfali23 opened 8 years ago
Hello,
You could use allowedMimeType. You can find all mime types on here
this.uploader = new FileUploader({
url: 'https://evening-anchorage-3159.herokuapp.com/api/',
allowedMimeType: ['image/png', 'image/gif', 'video/mp4', 'image/jpeg']
});
In order for the actual file selector to also filter for specific file types, you will need to add the mimetypes to the html input aswell, like so:
<input type="file" ng2FileSelect [uploader]="uploader" accept="image/png,image/gif,video/mp4,image/jpeg">
Of course, you could also use a variable for both, so you don't have to hardcode it:
template:
<input type="file" ng2FileSelect [uploader]="uploader" [accept]="allowedMimeType.toString()">
class:
this.allowedMimeType = ['image/png', 'image/gif', 'video/mp4', 'image/jpeg'];
this.uploader = new FileUploader({
url: 'https://evening-anchorage-3159.herokuapp.com/api/',
allowedMimeType: this.allowedMimeType
});
Is there any way to add filter on file name? As I need to allow only those files which have a numeric name.
Hi,
How to get error response if I try to browse file which is not mentioned in allowedMimeType?
I'm not sure you can prevent anyone from browsing files that are not in allowedMimeType, since the file selector is native to the browser, not this component. But you could always check the selected file(s) after closing the file selector, but before uploading, and remove any files that do not match the allowedMimeType.
seems not working with chrome and "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" - .xlsx
Hi,
I would like to filter file with specific extension. Does anyone know how to accomplish this?
Regards,
Farhan