2013-03-08 3 views
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); 
    } 

이클립스를 통해 안드로이드 에뮬레이터에서 정상적으로 작동합니다. 업로드 버튼을 누르면 업로드 할 파일을 묻습니다. apk 파일이 phonegap에 의해 생성 될 때 장치에서 업로드 버튼이 작동하지 않으면 실패합니다. phonegap.js도 제거해야합니다.빌드 후 phonegap 업로드 문제

답변

0

카메라 플러그인이 config.xml에 추가 되었습니까?

<plugin name="Camera" value="org.apache.cordova.CameraLauncher" /> 
0

당신은 phonegap.js를 제거해야한다고합니까?

그렇다면 앱에있는 특정 phonegap.js에 의존하는 장치 API에 액세스 할 수 없습니다. 이것은 PhoneGap Build에서 빌드시 삽입됩니다.