Making an iOS file input go directly to the camera

2019-03-25 11:52发布

问题:

Background: iOS 6.1, at the time of writing, doesn't allow both multiple file selection and taking a photo in a single input.

Since my main app already has a multiple input picker for choosing files, I'd like to add a second button (only required by, and only shown on) iOS devices to start the camera.

This currently works with:

<input type="file" class="ios_only" accept="image/*;capture=camera">

However iOS Safari always gives the following dialog:

Is there a way the <input> can be made to go directly to the camera without this prompt?

回答1:

No, you can't. Safari handles this as an UIImagePickerView and has to choose the source by this UIActionSheet.

For your information, this line has the same effect:

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

Tested also in iOS 7.



回答2:

For multiple file uploads:

<input capture="camera" accept="image/*" multiple="multiple" type="file" name="photo" id="photo" value="" />