在我的应用程序中,我想上传一个文件,然后以CSV格式导出。但是,我希望它保留文件的原始名称。我该怎么办?
document.getElementById("export").addEventListener("click",function(){
var download = "test";
this.setAttribute('href', 'data:text/html,' + encodeURIComponent(download));
},false)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body><input id="openFile" class="btn btn-light" type="file" />
<br>
<br>
<a id="export" download="export.csv">CSV Export</a>
</body>
</html>