this is a page I found from the Internet. I probably modified it a little bit, but there was no response after clicking the import button. Is there something wrong with the code, or this path is not written, but I can"t find a place to write. Please know how to give me some advice. Thank you!
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UFT-8">
<script src="jquery-1.8.2.js" ></script>
<script src="FileSaver.js" charset="utf-8"></script>
</head>
<body >
<div>
<div>
<input type="file" id="files" style="display:none" onchange="fileimport();"/>
<input type="button" id="import" value=""/>
<input type="button" id="export" value=""/>
</div>
</div>
<script>
var txtdata;
function fileimport()
{
var selectedFile = document.getElementById("files").files[0];//File
var name = selectedFile.name;//
var size = selectedFile.size;//
console.log(":"+name+":"+size);
var reader = new FileReader();//
reader.readAsText(selectedFile,"gb2312");//
reader.onload = function(){
console.log(this.result);//result
$("" + this.result + "
"). AppendTo ("body");
Txtdata = this.result;
};
}
$(document) .ready (function () {
/ / alert ("start");
Click (function () {/ / Click the import button to make files trigger the click event, and then finish reading the file.
$("- sharpfiles"). Click ();
});
$("- sharpexport") .click (function () {
Var content = "this is exported directly using HTML5:" + txtdata;
Var blob = new Blob ([content], {type: "text/plain;charset=utf-8"});
SaveAs (blob, "file.txt"); / / saveAs (blob,filename) / / only in the download directory of chorme
/ / alert ("export OK")
});
})
< / script >
< / body >
< / html >