diff --git a/lib/middleware/directory.js b/lib/middleware/directory.js
index a949f19..d25e752 100644
--- a/lib/middleware/directory.js
+++ b/lib/middleware/directory.js
@@ -39,6 +39,11 @@ const directory = (req, res, { path, uploadFile = true } = {}) => {
+ ``
+ ''
+ 'Download'
+ + ''
+ + ``
+ + ''
+ //+ ''
+ + 'Remove'
+ ''
+ ''
+ '';
@@ -47,12 +52,16 @@ const directory = (req, res, { path, uploadFile = true } = {}) => {
+= '
'
+ ''
+ `${file}`
- + `'
+ + ``
+ 'Open folder'
+ ''
+
+ + ``
+ + ''
+ //+ ''
+ + 'Remove Folder'
+ + ''
+
+ '';
}
});
diff --git a/lib/middleware/file-remove.js b/lib/middleware/file-remove.js
new file mode 100644
index 0000000..4032d23
--- /dev/null
+++ b/lib/middleware/file-remove.js
@@ -0,0 +1,23 @@
+
+const fs = require('fs-extra');
+
+const fileRemove = async (req, res, { path } = {}) => {
+
+ await new Promise((resolve, reject) => {
+
+ fs.remove(path, err => {
+ if(err) {
+ reject(err);
+ }else{
+ resolve();
+ }
+
+ });
+
+ });
+ return res.redirect('/');
+};
+
+module.exports = {
+ fileRemove,
+};
diff --git a/lib/middleware/index.js b/lib/middleware/index.js
index 47fbf86..c1e1bca 100644
--- a/lib/middleware/index.js
+++ b/lib/middleware/index.js
@@ -1,9 +1,17 @@
const querystring = require('node:querystring');
const { directory } = require('./directory');
const { fileUpload } = require('./file-upload');
+const { fileRemove } = require('./file-remove');
const { authMiddleware } = require('./auth');
const handler = (req, res, { path, uploadFile = true } = {}) => {
+
+ if(req.query.delete && req.query.delete.toLowerCase() === 'true'){
+ return fileRemove(req, res, {
+ path: path.replace(/[/]$/, '') + '/' + req.path.replace(/^[/]/, '')
+ });
+ }
+
if (req.method === 'POST' && uploadFile) {
const query = querystring.decode(req.url, null, null);
if (query && !query.path) {