Hello everybody
From an “input type = file” tag I retrieve the content of a local text file, therefore chosen by the user.
I modify this content retrieved in a string, and I would like to rewrite this file locally, so as to have the file modified locally.
Could someone show me how to do this
<body>
<h1>Welcome to Prjtest!</h1>
<input type="file" id="myFile">
<hr>
<textarea style="width:500px;height: 400px" id="output"></textarea>
</body>
Template.body.rendered = function() {
let input = document.getElementById("myFile");
let output = document.getElementById("output");
input.addEventListener("change", function () {
if (this.files && this.files[0]) {
let myFile = this.files[0];
let reader = new FileReader();
reader.addEventListener('load', function (e) {
output.textContent = e.target.result;
});
reader.readAsBinaryString(myFile);
}
});
}
thank you
YC