File uploads in HTML
A file input, the accept filter, and the encoding the form needs.
<form action="/api/import" method="post"
enctype="multipart/form-data">
<label for="csv">Results export</label>
<input type="file" id="csv" name="csv" accept=".csv,text/csv" required>
<label for="shots">Screenshots</label>
<input type="file" id="shots" name="shots" accept="image/*" multiple>
<button type="submit">Upload</button>
</form>
How it works
enctype=multipart/form-datais required to post files.acceptfilters the picker by type or extension.multipleallows more than one file per field.
The run, in numbers
- Lines
- 10
- Characters to type
- 340
- Tokens
- 81
- Three-star pace
- 70 tpm
At the three-star pace of 70 tokens a minute, this run takes about 69 seconds.
Step 3 of 4 in Numbers, dates & files, step 17 of 25 in Forms & inputs.