0
    function getImage() {
        Retrieve image file location from specified source
        navigator.camera.MediaType.ALLMEDIA
        navigator.camera.getPicture(uploadPhoto, function(message) {
        alert('File Not Selected');
    },{
        quality: 50, 
        destinationType: navigator.camera.DestinationType.FILE_URI,
        sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
        mediaType: navigator.camera.MediaType.ALLMEDIA
    }
        );

    }

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

        var params = new Object();
        params.value1 = "test";
        params.value2 = "param";

        options.params = params;
        options.chunkedMode = false;

        var ft = new FileTransfer();
        ft.upload(imageURI, "abc.php", win, fail, options);
    }

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

    function fail(error) {
        alert("An error has occurred: Code = " +error.code);
    }

这可以通过 eclipse 在 android 模拟器上正常工作。当按下上传按钮并要求上传文件时;当在设备上运行 phonegap 创建 apk 文件时,它会失败,没有上传按钮工作。我还必须删除 phonegap.js。

4

2 回答 2

0

是否将相机插件添加到 config.xml 中?

<plugin name="Camera" value="org.apache.cordova.CameraLauncher" />
于 2013-12-21T03:14:01.413 回答
0

你说你必须删除 phonegap.js ?

如果这样做,您将无法访问任何设备 API,因为它们依赖于应用程序中特定于设备的 phonegap.js。这将在 PhoneGap Build 的构建时注入。

于 2013-12-23T01:13:08.893 回答