1

私は今、数日間これを理解しようとしています。チュートリアルとドキュメントはすべて同じことを言っています。

ユーザーがカメラで撮影した写真をアップロードしたい。ただし、エラー関数にヒットし続け、コード、ソース、およびターゲットが null であると言い続けます。私のサーバーはヒットすることはなく、それについては何もないようです。これが私のコードです。

$(function() {

$('#camera').click(function() {
    navigator.camera.getPicture(upload, function() {
        alert('error');
    },
    {
        quality: 50, 
        destinationType: navigator.camera.DestinationType.FILE_URI,
        sourceType: navigator.camera.PictureSourceType.CAMERA
    }); 
});

var upload = function(image) {

    console.log(image);

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

    console.log(image.substr(image.lastIndexOf('/')+1));

    options.chunkedMode = true;

    var ft = new FileTransfer();
    ft.upload(image, encodeURI("http://mysite/upload.php"), win, fail, options);

};

function win(r) {
    console.log("Code = " + r.responseCode);
    console.log("Response = " + r.response);
    console.log("Sent = " + r.bytesSent);
}

function fail(error) {
    alert("An error has occurred: Code = " + error.code);
    console.log("upload error source " + error.source);
    console.log("upload error target " + error.target);
}

});

config.xml

<access origin="*" />
4

1 に答える 1