Example:
I have
var r = new FileReader();
    r.onload = function(e) {
        drawGraph(r.result);
    }
    r.readAsText(f);
drawing a graph from the file f input by the user.
Is there a way to check to see if the file f has been changed and then re load it's content without needing for the user to pick the file again?
Yes, this can be achieved using Node.js's filesystem API which provides a "watch" function
NodeJS Filesystem API docs: https://nodejs.org/api/fs.html
Similar question: Observe file changes with node.js
fs.watch('somedir', function (event, filename) {
    console.log('event is: ' + event);
    if (filename) {
        console.log('filename provided: ' + filename);
    } else {
        console.log('filename not provided');
    }
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With