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.
I've spent a lot of time searching right scripts for it but nothing works
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
thanks for your help!
<div class="row form-group">
<div class="col-md-12">
<input type="button" onclick="addCard()" id="addBtn" value="Добавить"
class="btn btn-primary py-2 px-4 text-white btn-lg">
<input type="button" onclick="saveHtml()" value="Сохранить"
class="btn btn-primary py-2 px-4 text-white btn-lg">
</div>
</div>
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);
}