Limited file types displayed in the viewport

Is NO WAY AT ALL really restricting the types of files that appear in the view file window? I tried this:

<input type="file" accept="text/xml" name="parameter_file" />

Firefox, IE just ignores it. I found the following excerpt from another question:

The Accept attribute was introduced in RFC 1867, intending to enable file filtering based on the MIME type for the file selection control. But most, if not all, browsers do not use this attribute.

How else can I do this? I know that you can achieve this with Flash, but I really don't want to use Flash.

I will check the selected file type on the server side, but I would like to improve the user interface by simplifying the display of only XML files.

Thanks to everyone for any help.

+3
source share
2 answers

AFAIK, there is no way to do this. The next best thing would be to use JS to check the file extension before submitting the form so that the user does not waste time downloading a file that is not accepted, but the server-type file type checking procedure should also be stored, because the first method could be easily circumvented by disabling JS.

Here's the jQuery solution: How to limit jQuery file types at boot time?

Hope this helps.

+3
source

It is not possible (for the programmer) to influence the file dialog opened with <input type=file> This is a security feature and nothing can be done about it.

( , , ), ( java- ..).

, , IIRC, YUI .

0

Source: https://habr.com/ru/post/1768595/


All Articles