Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force uploading file from camera without choosing in gallery on IOS?

Tags:

html

ios

I wanna force uploading file from camera without choosing in gallery on IOS, I have tried to use this code but it just work on android, not IOS (Safari):

<input type="file" accept="image/*" capture="camera" />
like image 871
Thanh Son Nguyen Avatar asked Nov 13 '15 08:11

Thanh Son Nguyen


1 Answers

That is possible.

Solution A(better compatibility):

  1. Create a video element, and streams data from your camera to it using getUserMedia.
  2. Create a canvas element, which renders what the video element renders.
  3. Capture image from the canvas element.

Solution B(easier):

<input type="file" accept="image/*" capture />

Tested on iOS 12 Safari

like image 100
EnixCoda Avatar answered Oct 05 '22 20:10

EnixCoda