Use JavaScript to retrieve a value from a txt file
wanwanwan
-
Hadus -
Hadus -
Hello,
After a few hours of research, I haven't necessarily found the right solution to my problem.
Indeed, I want to execute a script from an HTML page that retrieves the only variable recorded in a .txt file. My variable is an int value.
I assume the script should be very simple, but so far nothing has satisfied me. So, could someone please guide me on how to do it?
In my mind, it should look something like this:
<script>
var value = readFile("c://User/folder/folder/file.txt")
var myvalue = value
</script>
Thank you.
Configuration: Windows / Firefox 87.0
After a few hours of research, I haven't necessarily found the right solution to my problem.
Indeed, I want to execute a script from an HTML page that retrieves the only variable recorded in a .txt file. My variable is an int value.
I assume the script should be very simple, but so far nothing has satisfied me. So, could someone please guide me on how to do it?
In my mind, it should look something like this:
<script>
var value = readFile("c://User/folder/folder/file.txt")
var myvalue = value
</script>
Thank you.
Configuration: Windows / Firefox 87.0
3 answers
Hello,
You do not specify whether you are using node.js or not.
If not, you should be able to try this
https://stackoverflow.com/questions/14446447/how-to-read-a-local-text-file
--
.
Best regards,
Jordane
You do not specify whether you are using node.js or not.
If not, you should be able to try this
https://stackoverflow.com/questions/14446447/how-to-read-a-local-text-file
--
.
Best regards,
Jordane