Use JavaScript to retrieve a value from a txt file

wanwanwan -  
 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

3 answers

jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention   4 830
 
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
0