Is it possible to remove the option all files in the file explorer?

Asked

Viewed 394 times

3

With accept I can specify which formats are accepted.

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

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

explore

It is possible to remove this option and leave only the one I want?

  • takes the file name, and cuts the string the last 4 characters (which will be the file extension), then just have an array of extensions that are accepted, and check if the extension is in the array, if it is registered, if not, warns the user that the file n has been sent

  • This validation is already done, but I just wanted to know if it is possible to delete 'all files' from select in the explorer, if I am not mistaken, I’ve seen this option disabled when choosing files.

  • 1

    @Felipeduarte you may have seen this option unavailable or disabled in a specific program made in another language. In the browser, at least in the largest there is no such limitation.

3 answers

4


Using HTML only Is not possible.

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

Only programs running directly on the operating system and with permission to explore files on the computer can do this kind of limitation as you can see in the image below:

Filtro tipo de arquivo efetuado pela aplicação

If your app could communicate with any other being executed in the Operating System this would be possible.

1

It is only possible to set the start pattern... that is marked, but if you want, you can change the file extension when it is time to explore files, as it is in your image.

But you can receive the files and handle when registering or actually save the files, do the extension check

1

The option used only leaves the desired type marked as default. It is not possible to remove this option (at least until today).

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.