HTML: input type="file"

A file input lets a user choose one or more local files to send with a form.

What you will learn

Minimal example

<form action="/upload" method="post"
      enctype="multipart/form-data">
  <label for="avatar">Profile image</label>
  <input id="avatar" name="avatar" type="file"
         accept="image/*">
  <button type="submit">Upload</button>
</form>

The encoding type allows the request to carry file data. accept can guide the file picker, but it does not enforce what a user or an attacker submits.

Common mistakes