title: How to save html to .html file in folder on server with javascript
body: <p>I'm writing a tool for my website like an admin panel where you can add some elements to the page. Using javascript I add elements and then if save button is pressed everything should save automatically like "smth.html" to the same folder where the js script is.</p>
  
  <p>I've spent a lot of time searching right scripts for it but nothing works</p>
  
  <p>Can you advise me some solution to this problem, please? Is it possible to do it with code below? Code bellow helps to download it from webpage, but I need to save it to the server with script</p>
  
  <p>thanks for your help!</p>
  
  <pre class="lang-html prettyprint-override"><code>
  &lt;div class="row form-group"&gt;
     &lt;div class="col-md-12"&gt;
        &lt;input type="button" onclick="addCard()" id="addBtn" value="Добавить"
            class="btn btn-primary py-2 px-4 text-white btn-lg"&gt;
        &lt;input type="button" onclick="saveHtml()" value="Сохранить"
            class="btn btn-primary py-2 px-4 text-white btn-lg"&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  
  </code></pre>
  
  <pre><code>
  function saveHtml() {
      var html = document.querySelector("html").innerHTML;
  
      download("saved.html", html);
  }
  
  
  function download(filename, text) {
          var element = document.createElement('a');
          element.setAttribute('href', 'data:text/plain;charset=utf-8,' +
              encodeURIComponent(text));
          element.setAttribute('download', filename);
  
          element.style.display = 'none';
          document.body.appendChild(element);
  
          element.click();
  
          document.body.removeChild(element);
      }
  
  </code></pre>