Is it possible to remove all files in file explorer?

3

With accept I can set which formats are supported.

<input type="file" accept="image/png">

It filters, however in the explorer it is still possible to select all the files as in the photo.

Is it possible to remove this option and leave only the one I want?

    
asked by anonymous 08.11.2017 / 14:38

3 answers

3

Using only HTML Unable .

This is because the file search window in the input file tag is from the Operating System. The accept attribute communicates the Operating System to the initially supported file types or types, helping the user find the accepted files, but nothing prevents the "All Files" option from being selected.

Only programs running directly on the operating system and allowed to scan files on the computer can do this type of limitation as you can see in the image below:

  

If your application was able to communicate with someone else being   executed on the Operating System this would be possible.

    
08.11.2017 / 16:16
1

The option used only leaves the desired type checked by default. You can not remove this option (at least until today).

I think the best thing to do in case you do not want files of certain types is to validate through the server (using NodeJS, PHP or other languages, for example).

    
08.11.2017 / 16:20
1

You can only set the start pattern ... which is marked, but if you want, you can change the file extension when exploring files, just as it is in your image.

But you can receive the files and handle the time to register or actually save the files, do the extension verification

    
08.11.2017 / 14:49