0
我aswer我相信很容易。我需要創建一個代碼來獲取FileReader函數中的base64內容以發送到數據庫。我嘗試將base64字符串放在隱藏的表單類型中,但我無法做到。我上傳波紋管的源代碼:Javascript base64轉換
<script type="text/javascript">
function readMultipleFiles(evt) {
//Retrieve all the files from the FileList object
var files = evt.target.files;
if (files) {
for (var i=0, f; f=files[i]; i++) {
var r = new FileReader();
r.onload = (function(f) {
return function(e) {
var contents = e.target.result;
alert(
"name: " + f.name + "n"
+ "starts with: " + contents.substr(1, contents.indexOf("n"))
);
document.write(f.name);
};
})(f);
r.readAsText(f);
}
} else {
alert("Failed to load files");
}
}
document.getElementById('fileinput').addEventListener('change', readMultipleFiles, false);
</script>
https://jsfiddle.net/41ynj4gc/ – Jaccon