最初は 1 つの画像アップローダーを正常にアップロードしようとしていますが、2 回目にアップロードしようとすると、この種のエラーが発生します。誰でもこの問題を解決する方法を思いつくことができますか? 私はこれを使おうとしています
W/FileTransfer(12197): Error getting HTTP status code from connection.
W/FileTransfer(12197): java.io.EOFException
W/FileTransfer(12197): at libcore.io.Streams.readAsciiLine(Streams.java:203)
W/FileTransfer(12197): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
W/FileTransfer(12197): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
W/FileTransfer(12197): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
W/FileTransfer(12197): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
W/FileTransfer(12197): at org.apache.cordova.FileTransfer$1.run(FileTransfer.java:400)
W/FileTransfer(12197): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
W/FileTransfer(12197): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
W/FileTransfer(12197): at java.lang.Thread.run(Thread.java:856)
D/dalvikvm(12197): GC_CONCURRENT freed 976K, 31% free 2992K/4292K, paused 6ms+13ms, total 130ms
E/FileTransfer(12197): {"target":"http:\/\/10.2.4.142:8899\/assets\/www\/php\/upload.php","source":"\/mnt\/sdcard\/req_images\/gi.jpg","http_status":0,"code":3}
E/FileTransfer(12197): java.io.EOFException
E/FileTransfer(12197): at libcore.io.Streams.readAsciiLine(Streams.java:203)
E/FileTransfer(12197): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
E/FileTransfer(12197): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
E/FileTransfer(12197): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
E/FileTransfer(12197): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
E/FileTransfer(12197): at org.apache.cordova.FileTransfer$1.run(FileTransfer.java:400)
E/FileTransfer(12197): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
/FileTransfer(12197): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
E/FileTransfer(12197): at java.lang.Thread.run(Thread.java:856)
E/FileTransfer(12197): Failed after uploading 25310 of 25310 bytes.
<!DOCTYPE html>
<html>
<head>
<title>Capture Photo</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
<script src="js/jquery.js"></script>
<script type="text/javascript" src="js/imgresizerplugin.js"></script>
<script type="text/javascript" charset="utf-8">
var pictureSource;
var destinationType;
var fullsourcepath;
var options;
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
}
$(document).ready(function () {
$("#getphoto").click(function (source) {
navigator.camera.getPicture(onPhotoURISuccess, onFail, {
quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: pictureSource.PHOTOLIBRARY
});
});
$("#uploadpic").click(function () {
var rname = $("#rname").val();
console.log(rname);
if (fullsourcepath != null) {
imgresizerplugin.resize(function (winParam) {
options = new FileUploadOptions();
options.fileKey = "photo";
options.fileName = winParam.substr(winParam.lastIndexOf('/') + 1);
options.mimeType = "image/jpeg";
var params = {};
params.value1 = "test";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(winParam, encodeURI("http://10.2.4.142:8899/assets/www/php/upload.php"), win, fail, options);
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
$("#imgs").css("display", "none");
$("#rname").val("");
fullsourcepath = null;
}
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);
}
}, function (e) {
alert(' Failed:' + e);
}, fullsourcepath, rname);
} else {
alert("Please select Image");
}
});
function onPhotoURISuccess(imageURI) {
// alert(imageURI);
window.resolveLocalFileSystemURI(imageURI,
function (entry) {
console.log("fullpath::" + entry.fullPath);
/* cordova.exec(function(winParam) {console.log("getpath:" +winParam)}, function(error) {},"Imgresizer", "imgresizer", [entry.fullPath]);
*/
fullsourcepath = entry.fullPath;
var fileNameIndex = entry.fullPath.lastIndexOf("/") + 1;
var filename = entry.fullPath.substr(fileNameIndex);
$("#rname").val(filename);
$("#imgs").attr('src', entry.fullPath);
$("#imgs").css("display", "block");
},
function (evt) {
console.log("evet code" + evt.code);
});
}
function onFail(message) {
alert('Failed because: ' + message);
}
});
</script>
</head>
<body>
<p>
<label for="rname">Image Rename :</label>
<input name="rname" id="rname" placeholder="" value="" type="text" />
</p>
<p>
<input type="button" id="getphoto" value="Get Pic from gallary" name="getphoto" />
<input type="button" id="uploadpic" value=" Upload Pic" name="uploadpic" />
</p>
<img id="imgs" width="300" height="300" />
</body>
</html>