Limiting Allowed Extensions?
I am using the Blazor Uploader.
I am attempting to restrict the file extension types I want the user to be able to upload. I am using syntax like:
<EjsUploader ID="UploadFiles" AllowedExtensions=".ahf" AutoUpload="false" >
While this adds "*.ahf" to the list of filters, it also leaves "*, *.gif, *.jpg, *.jpeg, " etc. I want the to only see *.ahf files. I don't want them uploading *.gif files.
Am I doing this right?
Thanks in advance,
Jason
SIGN IN To post a reply.
3 Replies
SP
Sureshkumar P
Syncfusion Team
March 17, 2020 08:56 AM UTC
Hi Jason,
Greetings from Syncfusion support.
Based on your shared information, we suspect that you want to restrict the allowed extensions with “*” notation. This is default behavior of html uploaders accept property. so, we suggest you remove the * notation to resolve the issue.
|
<EjsUploader ID="UploadFiles" AllowedExtensions=".ahf" AutoUpload="false" > |
Native uploader functionality: https://www.w3schools.com/code/tryit.asp?filename=GCWYIIMJZDN8
Regards,
Sureshkumar P
JI
Jason Irby
March 17, 2020 11:10 PM UTC
Sureshkumar,
Hi. Thanks for the reply.
I am using the attribute:
AllowedExtensions=".ahf"
I am seeing it properly excluding the invalid types from upload after they are selected (see below):

That is good.
The problem is, other types are not removed from the selection filter on the select dialog. In fact "*.*" is the default selection. So this creates a poor user experience by suggesting to them they they can pick any file type to up load that they want, but that is not true and it will reject upon validation. That is rudely misleading them.
It did add the "*,ahf" extension to the list, but I wanted it to remove the others so "*.ahf" is the only possible selection and the default selected. (see below)



So I want to be able to remove the options:
All File(*)
*.gif
*.jpg
etc
And only leave:
*.ahf
Is this a bug? If I provide an attribute AllowedExtensions=".ahf" I was expecting only the file types listed in the attribute to be in the filter list.
P.S. I don't want to use the native file input because I want all the other feature of the SyncFusion Uploaded like chunking, pause/resume etc.
Thanks,
Jason
PM
Ponmani Murugaiyan
Syncfusion Team
March 18, 2020 10:40 AM UTC
Hi Jason,
Query1: The problem is, other types are not removed from the selection filter on the select dialog. In fact "*.*" is the default selection. So this creates a poor user experience by suggesting to them they can pick any file type to up load that they want, but that is not true and it will reject upon validation.
We have validated your reported scenario in our end. By default, JavaScript cannot prevent the user from choosing “any type” in the native OS file select dialog box. Browsers will allow users to choose files of any type when manually switched. We can only provide default file type suggestion on the initial. Kindly refer to the following online blog explaining the scenario.
Stack-overflow: https://stackoverflow.com/questions/4328947/limit-file-format-when-using-input-type-file
Query2: Is this a bug? If I provide an attribute AllowedExtensions=".ahf" I was expecting only the file types listed in the attribute to be in the filter list.
No, this is not a bug in our end. This is the behavior of the browser as well as the native OS file select dialog box.
Regards,
Ponmani M
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
JI Jason Irby
- Mar 13, 2020 10:12 PM UTC
- Mar 18, 2020 10:40 AM UTC