none
Uploading image from windows phone RRS feed

  • Question

  • In my application, I'm trying to upload an image chosen from gallery or taken from camera to server. I'm using Camera plugin to get the image and FileTransfer plugin to upload my image. Ever since I updated my Cordova version to 6.0.0 uploading images from my windows phone gets an error but it still works fine on Android 4. This is my code:

    function capturePhoto() { navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, destinationType: destinationType.FILE_URI, sourceType: pictureSource.CAMERA, correctOrientation: true }); } function getPhoto(source) { navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, destinationType: destinationType.FILE_URI, sourceType: pictureSource.PHOTOLIBRARY }); } function onPhotoURISuccess(imageURI) { console.log(imageURI); var options = new FileUploadOptions(); options.fileKey = "myfile"; options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1); options.mimeType = "image/jpeg"; options.httpMethod = "POST"; options.chunkedMode = false; var ft = new FileTransfer(); ft.upload(imageURI, encodeURI(domainName + "/app_action/tools/upload/default.ashx?lang=fa&maximagesize=1024&minimagewidth=150&minimageheight=150&maximagewidth=700&action=addusermedia"), win, fail, options); } function win(r) { console.log(r.response); }

    function fail(error) {

    console.log(error.code);
        console.log(error.source);
        console.log(error.target);

    }

    I keep getting error code 1

    When I log the imageURI, I get blob:173FAAE9-680D-4FB6-A839-07230A277F4D I have also tried getting the NATIVE_URI which gives my imageURI as ms-appdata:///local/wp_ss_20160514_0001.png and also replacing the "appdata:" with an empty string

    Any suggestions or answer will be great

    Thanks in advance



    Monday, May 16, 2016 5:41 AM

All replies

  • Hi Sahar,

    I made a demo from your codes, and tested it on android and windows phone(Universal). I used FILE_URI and NATIVE_URI for imageURL, everything works fine. 

    Could you give more information about your testing device? And testing steps?

    And sharing a basic demo that can reproduce this problem will help a lot.

    Tuesday, May 24, 2016 6:43 AM