<script>
function uploadPhoto() {
var imageURI = document.getElementById('msg').textContent;
var fd = new FormData();
window.resolveLocalFileSystemURL(imageURI, function(fileEntry) {
fileEntry.file(function(file) {
var reader = new FileReader();
reader.onloadend = function(e) {
var imgBlob = new Blob([this.result], {type:"image/jpeg"});
fd.append('file', imgBlob);
fd.append('title', 'testing');
fd.append('desc', 'testing123');
fd.append('content', 'testing12345');
console.log(fd);
var request = new XMLHttpRequest();
request.open('POST', 'http://some_site.com/upload.php');
request.send(fd);
};
reader.readAsArrayBuffer(file);
}, function(e){window.alert('error getting file');});
}, function(e){window.alert('error resolving fs url');});
}
</script>
它说它已上载,但服务器上没有收到。这里的imageURI
是图像的路径,我没有问题。