I am new to node.js and I'm trying to build a gallery that adds a picture automatically to a html div, if an image is uploaded to a specific folder.
I'm using Chokidar as a listener in app.js.
var chokidar = require('chokidar');
var watcher = chokidar.watch('public/images/uploads', {ignored: /^\./, persistent: true});
watcher
.on('add', function(path) {console.log('File', path, 'has been added');})
.on('change', function(path) {console.log('File', path, 'has been changed');})
.on('unlink', function(path) {console.log('File', path, 'has been removed');})
.on('error', function(error) {console.error('Error happened', error);})
The console output is working, but my question is: How can I add an image tag to my html div, everytime the watcher.on(...) function is called?
Something like this:
<div id="myImages">
<img name="img 1" "src="..." alt="..."/>
<img name="img 2" "src="..." alt="..."/>
</div>
I'm very thankful for every answer.
Regards
Aucun commentaire:
Enregistrer un commentaire