Hi guys Im trying to upload an image from camera capture on Cordova and sending to PHP file. The images sent to the PHP file comes like this:
data:image/jpeg;base64,file:///data/user/0/mobi.monaca.debugger/cache/1650991444040.jpg
How do I save this as actual image file on my server?
Thanks
CodePudding user response:
I solved it myself, it was true as Sammitch pointed out, I wasn't sending the local file.
I now solved it this way:
function onSuccess(imageData) {
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," imageData;
var file = "data:image/jpeg;base64," imageData;
$(".image-tag").val(file);
$('#plswait').html('Please wait...');
var wait=setTimeout("document.sendcapture.submit();",5000);
}
I have a HTML form that collects and sends the data to my PHP file, like so
<form method="POST" enctype="multipart/form-data" id="sendcapture" name="sendcapture" action="https://.....com/saveUploadImg" style="text-align: center;">
<input type="text" name="image" >
</form>
<div style="text-align: center;">
<button id = "cameraTakePicture">CAPTURE WITH CAMERA</button>
<img style="display: none;" id = "myImage"></img>
<br>
<div id="plswait" style="color: red; font-style: italic; font-weight: bold;"></div>