如何在科尔多瓦显示从相机拍摄的图像?(Xcode/iOS)



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

打开设备摄像头的功能是:

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;

但我不知道该怎么修,也不知道该如何修。

有人知道怎么解决这个问题吗?

我拿到了。

我换了

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

 smallImage.src = imageURI;

最新更新