Hi If i'm not mistaken you want to make a DELETE request with the file path to the route where you saved the file. if you can setup a route for this DELETE request like that:
router.delete('/uploads', (req, res, next) => { const path = req.body.path; // you can make use of the fs method unlink fs.unlink(path, (err) => { if (err) throw err; console.log('successfully deleted ', path); });) and in your app just prepare an ajax as described
var filename = 'path/to/file'; // get this from where you saved the file earlier
$.ajax({ url: "/uploads", data: { path: filename }, type: 'DELETE', success: function ( alert('file deleted'); }, error: function ( alert('file not deleted'); } });
Hi If i'm not mistaken you want to make a DELETE request with the file path to the route where you saved the file. if you can setup a route for this DELETE request like that:
router.delete('/uploads', (req, res, next) => { const path = req.body.path; // you can make use of the fs method unlink fs.unlink(path, (err) => { if (err) throw err; console.log('successfully deleted ', path); });)
and in your app just prepare an ajax as described var filename = 'path/to/file'; // get this from where you saved the file earlier$.ajax({ url: "/uploads", data: { path: filename }, type: 'DELETE', success: function ( alert('file deleted'); }, error: function ( alert('file not deleted'); } });