w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
HTML file upload accept and reject file extensions

For modern browsers you can use accept on an input element, you will have to add all the files you can accept and leave out the ones you reject. With just HTML this is all you can do, but it is easy to reject if you for example used JavaScript, PHP, etc. Since HTML is not a programming language what you can and can't do is rather limited.

<input type="file" accept="[everything but .exe and

As you mentioned you are going to have to place a good amount of files here. Unfortunately as of right now there is no reject attribute you can add.

Note: For support in order browsers you are going to need to use JavaScript or another programming language to check the input of the file. Otherwise from what I shown above is all you can do in just HTML.

I would recommend just buckling down and using JavaScript to check, it will be easier that way.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.