2

I'm testing a web application, where I came across a button. This button is supposed to start the client's camera application and then allow the user to upload a photo.

As I am testing from a virtual machine, there is no camera application and therefore the button simply does nothing for me.

After some research, I believe that the web application is built with/on cordova. I do have access to the JavaScript, which I believe, is responsible for the button action - but I can not share the code.

In summary this is what happens:

 var client_camera = navigator.camera;
 client_camera.getPicture(...)

Is there some way to make the browser/web application think that I do have a camera/camera application and thereby enable the upload of such a picture?

edit: Documentation of the discovered function can be found here

SaAtomic
  • 619
  • 1
  • 12
  • 29

1 Answers1

1

You can't bypass the camera action.

Anyway, navigator is an Object contains the client details (browser, OS & some components like camera, flash, etc.)

All I can suggest here is

Check if there is a camera.

If yes, use it.

If not, add a default file uploader

The code

if(navigator.camera){
  //camera is there add the code to capture from camera
}
else{
  var file=document.createElement('input');
  file.set attribute('type','file');
  //append it to the container div or body
  // assume that you have a div with class container
 document.querySelector('div.container').appendChild(file);

Then you can initiate the upload process while the file is choosen by using a change event Handler on the input element

Sagar V
  • 12,158
  • 7
  • 41
  • 68