0

I am able to access the camera and even save the image remotely, but I would like to show the image on the screen before I upload.

The function that opens the devices camera is:

function capturePhoto() {
                    navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 10, width: 412, height: 412, correctOrientation: 1, saveToPhotoAlbum: 1});
                }

The function that is triggered after the photo is initially taken is:

  function uploadImage() {
                imageURI = lastImage;

                // Get image handle
                var smallImage = document.getElementById('smallImage')

                smallImage.src = "data:image/jpeg;base64," + imageURI;


                var fail, ft, options, params, win;

                // callback for when the photo has been successfully uploaded:
                var success =  function(response) {
                    //alert(tags);
                    alert("Photo Saved");
                };

                // callback if the photo fails to upload successfully.
                var fail = function(error) {
                    alert("An error has occurred: Code = " + error.code);
                    alert(FileTransferError.CONNECTION_ERR);
                };
                 //FILE UPLOAD SCRIPTS
                options = new FileUploadOptions();
                options.fileKey = "my_image";
                options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
                options.mimeType = "text/plain";
                params = {
                    val1: tags,
                    val2: location
                };
                options.params = params;
                ft = new FileTransfer();
                ft.upload(imageURI, 'http://mysite.com/recieve.php', success, fail, options);

            }

And the HTML where the image is to be displayed:

     <img style="display :none;width:60px;height:60px;" id="smallImage" src="" />

I am assuming there is something wrong with the line

            smallImage.src = "data:image/jpeg;base64," + imageURI;

but I am not sure what or how to fix it.

Would anyone know how to ammend this?

1 Answer 1

0

I got it.

I changed the line

 smallImage.src = "data:image/jpeg;base64," + imageURI;

too

 smallImage.src = imageURI;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.