0

我可以访问相机,甚至可以远程保存图像,但我想在上传之前在屏幕上显示图像。

打开设备相机的功能是:

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

初始拍摄照片后触发的功能是:

  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);

            }

以及要显示图像的 HTML:

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

我假设这条线有问题

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

但我不确定什么或如何解决它。

有人知道如何修改吗?

4

1 回答 1

0

我知道了。

我换了行

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

 smallImage.src = imageURI;
于 2013-08-06T07:08:42.130 回答