Advertisement
Home Open Editor ❯

HTML <input> capture Attribute

This page is not complete.

Example

<label for="soundFile">Upload a sound: (user)</label>
<input type="file" id="soundFile" capture="user" accept="audio/*"><br><br>
<label for="soundFile2">Upload a sound: (environment)</label>
<input type="file" id="soundFile2" capture="environment" accept="audio/*">

<hr>

<label for="videoFile">Upload a video: (user)</label>
<input type="file" id="videoFile" capture="user" accept="video/*"><br><br>
<label for="videoFile2">Upload a video: (environment)</label>
<input type="file" id="videoFile2" capture="environment" accept="video/*">

<hr>

<label for="imageFile">Upload a photo: (user)</label>
<input type="file" id="imageFile" capture="user" accept="image/*"><br><br>
<label for="imageFile2">Upload a photo: (environment)</label>
<input type="file" id="imageFile2" capture="environment" accept="image/*">

Try this code ❯

Meaning

The capture attribute specifies that, optionally, a new file should be captured, and which device should be used to capture that new media of a type defined by the accept attribute.

The capture attribute is supported on the file input type.

The capture attribute takes as it's value a string that specifies which camera to use for capture of image or video data, if the accept attribute specifies that the input should be of one of those types.

Note: capture was previously a Boolean attribute which, if present, requested that the device's media capture device(s) such as camera or microphone be used instead of requesting a file input.

Note: capture attribute work better on mobile devices; if your device is a desktop computer, you'll likely get a typical file picker.


Standard Syntax

HTML:<input capture="user|environment">,
XHTML:<input capture="user|environment"/>


Advertisement

Attribute Values

Value Description
user The user-facing camera and/or microphone should be used.
environment The outward-facing camera and/or microphone should be used.
Home Open Editor ❯
Advertisement