title: Html/JavaScript: Overwrite file every time it downloads
body: <p>Is it possible to overwrite a file each time it saves. I have a textarea in html and i'm using JavaScript to save the text to a file. It is currently saving as: test.txt, test(1).txt, test(2).txt. Is it possible to get it to save a test.txt every time it's downloaded.</p>
  
  <p>The code i'm using to download is the following:</p>
  
  <pre><code>function saveTextAsFile()
  {      
      var textToWrite = document.getElementById("inputTextToSave").value;
      var textFileAsBlob = new Blob([textToWrite], {type:'plan/text'});
      var fileNameToSaveAs = "test.txt";
      var downloadLink = document.createElement("a");
      downloadLink.download = fileNameToSaveAs;
      downloadLink.innerHTML = "My Hidden Link";
      window.URL = window.URL || window.webkitURL;
      downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
      downloadLink.onclick = destroyClickedElement;
      downloadLink.style.display = "none";
      document.body.appendChild(downloadLink);
      downloadLink.click();
  }
  </code></pre>
  
  <p>Thanks for your help.</p>