2

I am writing a mobile application using PhoneGap that accesses the camera on the mobile device, when a user clicks the button to take a picture the option to use the camera appears, along with the option to use an image from an album already on the device. for security purposes, I would like to disallow this feature of uploading an image from an album. How would I go about doing this. Currently I have:

 <input id="files" name="files[]" type="file" multiple/>

which when clicked on an IOS or Android device prompts the user to select to either take an image or upload from an album. How can I modify this so that only the camera is selectable?

Thanks in advance.

mks
  • 199
  • 1
  • 15
  • Pretty much no way to do this with HTML5 and JS as of 2017. Maybe natively on Android or IOS, but not using PhoneGap at least – mks Jun 27 '17 at 21:11

1 Answers1

1

You could try using the capture attribute documented: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input

Or, you would have to use a custom camera control instead of the standard input control. Not all platforms will support the capture attribute, as you can see here: HTML file input control with capture and accept attributes works wrong?

Sean
  • 337
  • 2
  • 7
  • so pretty much, theres no way to do this? according to this answer on the page you linked, the choose existing will always appear with the take a photo dialogue. https://stackoverflow.com/a/23360323/6719920 – mks Jun 27 '17 at 20:41
  • 1
    Not with an HTML5 standard API. You can use a native Cordova/PhoneGap plugin as you suggested. – Sean Jun 27 '17 at 21:54