Hi
i am using multiplefileupload reactive component.i already mentioned supported file types but still i am able to upload zip file.how to resolve this thing.i am attaching the screenshot.
Hi Arkyadeep,
The FileType parameter would only accept the file content type and not the file extension. You can try something like "image/*".
You can add multiple types in this way: "image/*, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
It also depends on the browser. Some browsers strictly allow only mime types to be allowed, while some may allow file extensions too. But it's recommended to keep it to the content types only.
https://personal-t4mpz2cn.outsystemscloud.com/MultipleFileUploadReactive/FileUploadThis example works for images and xlsx files.
Here you can know more about browser behaviour on file extensions and content types. Although it is a very old response on stack overflow, but must be still somewhat relevant I believe.https://stackoverflow.com/a/3521281/1500601
PS: I deleted my previous comment becaused I wanted to do some tests and add some more details on my response.
Hi Arkyadeep Bharadwaj :)
Please refer to this documentation:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file
You should use the mime type, not the file extension in the input FileType of the component.
I also noticed that you are missing a comma between docx and jpeg. But you could use something like: "application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, text/plain, application/pdf, image/*"
With the above setting, I'm not able to upload a zip file, as you can see in the image bellow:
Let me know if this works :)
José
thanks for your reply.i am able to fix that issue but the problem is when i am trying to choose file that time if i choose all files then also i am able to upload zip file.i want to restrict the Zip file
Removing the “All files” option from the pop up is impossible: https://stackoverflow.com/questions/70697680/how-can-i-remove-all-files-option-from-html-file-input
You have to build some validation in your client or server logic to reject those files. You can, for example, look at the Mime type of the uploaded file and delete/reject it before storing it in the database or sending it to the server side.
Unfortunately, the accept attribute only hints the user on the type of files they can upload, but never prevents them from selecting the “All files”.
ok