【发布时间】:2015-11-22 17:26:35
【问题描述】:
Below 是我尝试本地存储我选择的文件状态但刷新后不存在的代码。如何使用本地存储来做到这一点?
<html>
<head>
<script>
function savedata(){
localStorage.SetItem("file",getElementById("store").value);
}
window.onload = function(){
document.getElementById("store").value = localStorage.getItem("file");
}
</script>
</head>
<body>
<form>
<input type ="file" id = "store" onchange="savedata();"/>
</form>
</body>
</html>
当我上传文件时,它显示为 somefilename.png/jpg。但是在我刷新页面后,它显示没有选择文件。我想要最后选择的文件名,即使在刷新后我也被选中。
即使我刷新页面后,它也应该显示以前的文件名,而不是没有选择文件怎么做?
【问题讨论】:
-
@Arun P Johny 这些答案并没有让我清楚,这就是我问的原因
标签: javascript jquery