For technical reasons, the title of this article is not the text used to call this API. Instead, use HTML Media Capture
The capture attribute facilitates user access to a device’s media capture mechanism, such as a camera, or microphone, from within a file upload control, for capturing media on the spot.
Applies to [HTMLInputElement](/dom/HTMLInputElement)The capture attribute is a boolean attribute that, if specified, indicates that the capture of media directly from the device's environment using a media capture mechanism is preferred.
The capture attribute applies to input elements when the type attribute’s value is file and its accept attribute is specified. If the accept attribute’s value is set to a MIME type that has no associated capture control type, the user agent acts as if there was no capture attribute.
The media capture mechanism builds upon the security and privacy protections provided by the <input type="file"> and the File API specifications; in particular, any offer to start capturing content from the user’s device requires a specific user interaction on an HTML element that is entirely controlled by the user agent.
ExamplesIndicates that image files are accepted to be captured.
<input type="file" accept="image/*" capture>
Indicates that video files are accepted to be captured.
<input type="file" accept="video/*" capture>
Indicates that audio files are accepted to be captured.
<input type="file" accept="audio/*" capture>
To take a picture using the device’s camera, and upload the picture taken using an HTML form.
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="image" accept="image/*" capture>
<input type="submit" value="Upload">
</form>
To capture a video using the device’s local video camera, and upload the picture taken using an HTML form.
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="video" accept="video/*" capture>
<input type="submit" value="Upload">
</form>
To capture audio using the device’s local microphone, and upload the picture taken using an HTML form.
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="audio" accept="audio/*" capture>
<input type="submit" value="Upload">
</form>
Related specifications
capture
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4