Filter file with specific extension #348
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
I would like to filter file with specific extension. Does anyone know how to accomplish this?
Regards,
Farhan
Hello,
You could use allowedMimeType. You can find all mime types on here
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:
Of course, you could also use a variable for both, so you don't have to hardcode it:
template:
class:
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