--- url: "https://web.dev/articles/media-capturing-images" titulek: "Capturing an image from the user | Articles | web.dev" h1: "Capturing an image from the user Stay organized with collections Save and categorize content based on your preferences." popis: "Most browsers can get access to the user's camera." jazyk: "en" kanonicka: "https://web.dev/articles/media-capturing-images" drobecky: ["Articles", "Capturing an image from the user"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 22:29:15" znaku: 12726 slov: 1899 kodovani: "iso-8859-2" sha256: "6bd3102d65122f630c9553e5de5a324fba467537ef0a2606fddb3bb55a69a629" --- Capturing an image from the user Stay organized with collections Save and categorize content based on your preferences. Most browsers can get access to the user's camera. Mat Scales Paul Kinlan Many browsers now have the ability to access video and audio input from the user. However, depending on the browser it might be a full dynamic and inline experience, or it could be delegated to another app on the user's device. On top of that, not every device even has a camera. So how can you create an experience that uses a user generated image that works well everywhere? Start simple and progressively If you want to progressively enhance your experience, you need to start with something that works everywhere. The easiest thing to do is simply ask the user for a pre-recorded file. Ask for a URL This is the best supported but least satisfying option. Get the user to give you a URL, and then use that. For just displaying the image this works everywhere. Create an `img` element, set the `src` and you're done. Though, if you want to manipulate the image in any way, things are a bit more complicated. [CORS](https://developer.mozilla.org/docs/Web/HTTP/Access_control_CORS) prevents you from accessing the actual pixels unless the server sets the appropriate headers and you [mark the image as crossorigin](https://developer.mozilla.org/docs/Web/HTML/CORS_enabled_image) ; the only practical way around that is to run a proxy server. File input You can also use a simple file input element, including an `accept` filter that indicates you only want image files. `` This method works on all platforms. On desktop it will prompt the user to upload an image file from the file system. In Chrome and Safari on iOS and Android this method will give the user a choice of which app to use to capture the image, including the option of taking a photo directly with the camera or choosing an existing image file. The data can then be attached to a `