Using jQuery and Javascript to open an iOS camera application and save it as a variable

Is it possible that I can use jQuery and Javascript so that I can open the camera application in iOS, take a picture and save this image in a variable so that I can, rather than load it into parsing?

I do not like this because you have no control over the image.

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

thanks

+7
javascript jquery
source share
1 answer

You can use the file API along with the generated nor visible input [type = "file"], which will leave you with a file that you can then use as a binary, or as in the example below, as a base64 url, which can then be transferred to the server .

 var btn = document.getElementById('upload-image'), uploader = document.createElement('input'), image = document.getElementById('img-result'); uploader.type = 'file'; btn.onclick = function() { uploader.click(); } uploader.onchange = function() { var reader = new FileReader(); reader.onload = function(evt) { image.src = evt.target.result; } reader.readAsDataURL(uploader.files[0]); } 
 <button id="upload-image">Select Image</button> <img id="img-result" style="max-width: 200px;" /> 
+2
source share

All Articles