phonegap apiでFileTransfer.uploadを使用して画像をアップロードしようとしましたが、エラーが発生します。エラーは「接続エラー」で、エラーコードは3です。
Here is my code.
<!DOCTYPE html>
<html>
<head>
<title>Video Uploader</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="master.css" type="text/css" />
<script type="text/javascript" charset="utf-8"src="phonegap-1.1.0.js"></script>
<script src="Scripts/jQuery-1.6.1.min.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
function getphoto(){
navigator.camera.getPicture(uploadPhoto,function(message) {
alert('get picture failed');
},{ quality:10,destinationType:navigator.camera.DestinationType.FILE_URI,sourceType:navigator.camera.PictureSourceType.PHOTOLIBRARY });
}
function uploadPhoto(imageURI) {
document.getElementById("myimg").src=imageURI;
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, "http://xxxx.asmx", win, fail, options,true);
}
function win(r) {
alert("Response = " + r.response);
alert("Sent = " + r.bytesSent);
}
function fail(error) {
switch (error.code) {
case FileTransferError.FILE_NOT_FOUND_ERR:
alert("Photo file not found");
break;
case FileTransferError.INVALID_URL_ERR:
alert("Bad Photo URL");
break;
case FileTransferError.CONNECTION_ERR:
alert("Connection error");
break;
}
alert("An error has occurred: Code = " + error.code);
}
</script>
</head>
<body >
<button onclick="getphoto();">get a Photo</button>
<button onclick="getphoto();">Upload a Photo</button>
<img src="" id="myimg" style="border:1px solid #0f0;height:200px;width:200px;" />
</body>
</html>
それを見て、解決策を教えてください.phonegapapiのupload.phpの概念は何ですか