Search code examples
htmluploadinputprogressfile-type

Filetype in HTML upload form


How can i limit my form to only accept jpeg files? Now it shows all files.

<input name="image" type="file" />

And are there any javascript method to show progress?


Solution

  • There is an accept attribute in the input tag, but it's not supported by all browsers. Here's an example:

    <input type="file" name="image" id="image" accept="image/jpeg" />
    

    It could be your first check, but your main check must be on the server when accepting the file.