A bit of an older post, but still relevant: Tapas Adhikary goes over some HTML attributes one can set on an input[type="file"]
, and uses of the File API:
- Simple file upload
- Multiple file uploads
- Know about file metadata
- Know about file
accept
property - Manage file content
- Validate file size
- Show file upload progress
- How about directory upload?
- Let’s drag, drop and upload
- Handle files with
objectURL
s
10 useful HTML file upload tips for web developers →
~
Not covered in Tapas’s article is the capture
attribute. Combined with accept
you can have a user on a mobile device immediately take a picture or video:
<!-- Capture photo using the front/selfie camera -->
<input type="file" accept="image/*" capture="user">
<!-- Capture photo using the back camera -->
<input type="file" accept="image/*" capture="environment">