Phone Gap FileTransfer插件上传问题

时间:2014-12-23 09:05:30

标签: cordova

我通过phonegap文件传输上传获得了本机代码错误:

  

无法读取未定义的属性上传

我正在使用visual studio 2013中的Apache cordova模板诙谐。

这是我的js代码。

function getPhoto(source) {
    // Retrieve image file location from specified source
    navigator.camera.getPicture(onPhotoURISuccess, onFail, {
        quality: 50,
        destinationType: destinationType.FILE_URI,
        sourceType: source
    });
}


    function onPhotoURISuccess(imageURI) {
        // Uncomment to view the image file URI 
        // console.log(imageURI);
        alert("Imagecalled");
        // Get image handle
        //
        var largeImage = document.getElementById('largeImage');

        // Unhide image elements
        //
        largeImage.style.display = 'block';

        // Show the captured photo
        // The inline CSS rules are used to resize the image
        //
        largeImage.src = imageURI;
        uploadPhoto(imageURI);
    }


function uploadPhoto(imageURI) {

    alert("uploadPhoto");
    debugger;
    var objUrl = _ServicesUrl._SecondServicePath + _ServicePage._BaseServicePage + _WcfFunctionUrl._ImageUpload;
    var serverUrl = objUrl;


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

    //var ft = new FileTransfer();
    //ft.upload(imageURI, serverUrl, this.win, this.fail, fileUploadOptions);


    var options = new FileUploadOptions();

    options.chunkedMode = false;

    options.fileKey = "recFile";

    var imagefilename = imageURI;

    options.fileName = imagefilename;
    options.mimeType = "image/jpeg";

    var ft = new FileTransfer();

    alert(imagefilename);

    ft.upload(imageURI, serverUrl, win1, fail1, options);

}

1 个答案:

答案 0 :(得分:0)

插件不起作用。他们执行本机代码。您应该尝试使用实际的模拟器。