3

enter image description hereBelow is the code that i tried to local storage the file state which i had selected but after refreshing it is not present.How to do it using local Storage?

<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>

when i am uploading a file it is showing as somefilename.png/jpg.But after i refreshed the page it is showing No file choosen.I want the last selected filename which I have been selected even after refresh.

Even after I refresh the page it should show the previous file name instead of no file choosen how to do that?

after I have refreshed the file it is showing no file choosen enter image description here

Vishnu Atrai
  • 2,370
  • 22
  • 24
CSiva
  • 137
  • 1
  • 1
  • 8

1 Answers1

1

The input will always lie to you what its real value is, so you can't get sensitive path info from the client's computer. The only thing you can discover is the filename, and by just using the filename, it's impossible to set it to the previous value.

alex
  • 479,566
  • 201
  • 878
  • 984