Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript phonegap多媒体资料上载图像_Javascript_Android_Cordova - Fatal编程技术网

Javascript phonegap多媒体资料上载图像

Javascript phonegap多媒体资料上载图像,javascript,android,cordova,Javascript,Android,Cordova,我正试图从图库中获取图像,但它不起作用 我从以下代码中得到的错误是: 上传失败:代码=3 上传图像 function uploadPicture() { // Get URI of picture to upload var img = document.getElementById('camera_image'); var imageURI = img.src; if (!imageURI || (img.style.display == "none"))

我正试图从图库中获取图像,但它不起作用

我从以下代码中得到的错误是:

上传失败:代码=3

上传图像

function uploadPicture() {  
    // Get URI of picture to upload
    var img = document.getElementById('camera_image');
    var imageURI = img.src;
    if (!imageURI || (img.style.display == "none")) {
        document.getElementById('camera_status').innerHTML = "Take picture or select picture from library first.";
        return;
    }

    // Verify server has been entered
    server = document.getElementById('serverUrl').value;

    if (server) {       
        // Specify transfer options
        var options = new FileUploadOptions();
        options.fileKey="file";
        options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
        options.mimeType="image/jpeg";
        options.chunkedMode = false;
        options.headers = {
           Connection: "close"
        };
        // Transfer picture to server
        var ft = new FileTransfer();
        ft.upload(imageURI, server, function(r) {
            document.getElementById('camera_status').innerHTML = "Upload successful: "+r.bytesSent+" bytes uploaded.";              
        }, function(error) {
            document.getElementById('camera_status').innerHTML = "Upload failed: Code = "+error.code;               
        }, options);
    }
}

看看插件代码,我看到了:“publicstaticint-CONNECTION\u ERR=3;”-你确定你的服务器参数是正确的吗?是的,因为我使用相机,它工作得很好!我使用了这段代码:我的phonegap应用程序使用了完全相同的逻辑,我们正在研究服务器端问题;)编辑:尝试删除文件扩展名,这是唯一与我的设置不同的地方