簡體   English   中英

AppGyver android顯示捕獲的圖像問題

[英]AppGyver android show captured Image Issue

我需要在ApGyver類固醇應用程序中顯示捕獲的圖像。 我捕獲了圖像,然后嘗試在圖像中設置src。 但這給了我不允許本地資源的錯誤:

我正在以這種方式捕獲圖像:

            var options = {
                quality: 50,
                targetWidth: 300,
                targetHeight: 300,
                destinationType: Camera.DestinationType.FILE_URI,
                sourceType: Camera.PictureSourceType.CAMERA, // Camera.PictureSourceType.PHOTOLIBRARY
                allowEdit: false,
                encodingType: Camera.EncodingType.JPEG,
                popoverOptions: CameraPopoverOptions,
                saveToPhotoAlbum: true,
                limit: 1
            };
            // capture callback
            var captureSuccess = function(mediaFiles) {
                var i, path, len;
                console.log(mediaFiles);
                for (i = 0, len = mediaFiles.length; i < len; i += 1) {
                    path = mediaFiles[i].localURL;
                    // do something interesting with the file
                }
                if (switched) {
                    $scope.post.media = []
                }
                $scope.post.media.length = 1;
                $scope.post.fileUrl = path;
                setActionType('image');
                $scope.isBusy = false;
                console.log('hello' + path);
            };

            // capture error callback
            var captureError = function(error) {
                navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
            };

            // start image capture
            navigator.device.capture.captureImage(captureSuccess, captureError, options);

嘗試使用此代碼來捕獲和上傳圖像。 並在index.html中鏈接cordova.js並添加相機插件。 仍然有任何問題告訴我。

function capturePhoto() {
         navigator.camera.getPicture(uploadPhoto, onFail, {
         quality: 50, 
         // allowEdit: true,
         correctOrientation: true,
         destinationType: Camera.DestinationType.FILE_URL,
         // destinationType: Camera.DestinationType.DATA_URL
         sourceType: Camera.PictureSourceType.CAMERA
     });
    }

    function onFail(message) {
    // alert('Failed because: ' + message);
    }

    function uploadPhoto(imageURI){
    console.log(imageURI);

    var options = new FileUploadOptions();
    options.fileKey="file";
    options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
    options.mimeType="image/jpeg";

    var ft = new FileTransfer();
    ft.upload(imageURI, encodeURI("http://XYZ/uploadimg?user_id="+UserId+""),  winGallary, fail, options);
    console.log(ft.upload);
    }

    function winGallary(rGallary) {
        console.log("Code = " + rGallary.responseCode);
        console.log("Response = " + rGallary.response);
        console.log("Sent = " + rGallary.bytesSent);

    }

    function fail(error) {
    console.log("upload error source " + error.source);
    console.log("upload error target " + error.target);
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM