danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
MIT License
7.87k stars 1.6k forks source link

App script code To delete uploaded file. #2046

Open Nandinireddykondareddigari opened 6 years ago

oauthentik commented 6 years ago

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'); } });

leonardoampuero commented 6 years ago

hi, I am needing the same. is it possible to do this, changing the method to DELETE and adding some parameters?

Upload.upload({ url: "https://xxxxxx.s3.amazonaws.com/", method: 'DELETE', ....