The task is to load the file with HTML and JS. Code

<input type="file" class="file-for-import" /> 

A standard file upload form appears. I need to load only a certain type of files, for example, shp. How can i do this?

    1 answer 1

     <input type='file' accept='.shp,.csv'> 
    • It does not work exactly as needed. I need several extensions: for example, .shp and .csv. And when I specify only one of these types in the accept attribute, it works, but when I specify both, instead of the list of extensions in the loading window, it says "User types". How can I make the list of valid extensions visible to the user? - Mae
    • @NewDevelop, here only mime or comma. Alternatively, you can specify the allowed types next to input - Mr. Black
    • <input type="file" class="file-for-import" accept=".csv,.shp" /> with this code, I do not see extensions in the user form. - Mae
    • @NewDevelop, yes, but the filter is applied. If you create files 1.csv , 2.shp and 3.txt in an empty folder, only the first two will appear in the window when selected . Black
    • @NewDevelop, even if you specify several mime types, "Other files" is displayed, because it does not fit several symbols in one line. The same with file type - Mr. Black