Try it
<label for="selfie">Take a picture of your face:</label>
<input type="file" id="selfie" name="selfie" accept="image/*" capture="user" />
<label for="picture">Take a picture using back facing camera:</label>
<input
type="file"
id="picture"
name="picture"
accept="image/*"
capture="environment" />
label {
display: block;
margin-top: 1rem;
}
input {
margin-bottom: 1rem;
}
Examples
When set on a file input type, operating systems with microphones and cameras will display a user interface allowing the selection from an existing file or the creating of a new one.
html
<p>
<label for="soundFile">What does your voice sound like?:</label>
<input type="file" id="soundFile" capture="user" accept="audio/*" />
</p>
<p>
<label for="videoFile">Upload a video:</label>
<input type="file" id="videoFile" capture="environment" accept="video/*" />
</p>
<p>
<label for="imageFile">Upload a photo of yourself:</label>
<input type="file" id="imageFile" capture="user" accept="image/*" />
</p>
Note these work better on mobile devices; if your device is a desktop computer, you'll likely get a typical file picker.
Specifications
| Specification |
|---|
| HTML Media Capture # dfn-capture |