diff --git a/index.js b/index.js index 78ee0ea..560f584 100644 --- a/index.js +++ b/index.js @@ -71,15 +71,26 @@ app.get("/", (req, res) => { res.redirect("/b") }) -app.post("/upload", uploads.single('file'), (req, res) => { - var file = req.file - fs.writeFileSync(path.join(__dirname, req.body.directory, file.originalname), file.buffer) - - res.redirect(req.body.directory) -}) - if (passwd) { app.get("/dashboard.html", (req, res) => { - res.send(fs.readFileSync(path.join(__dirname, 'resources/dashboard.html')).toString().replace("{DIRECTORY}", req.query.folder)) + var html = fs.readFileSync(path.join(__dirname, 'resources/dashboard.html')).toString() + while (html.includes("{DIRECTORY}")) { + html = html.replace("{DIRECTORY}", req.query.folder) + } + + res.send(html) + }) + + app.post("/upload", uploads.single('file'), (req, res) => { + var file = req.file + fs.writeFileSync(path.join(__dirname, req.body.directory, file.originalname), file.buffer) + + res.redirect(req.body.directory) + }) + + app.post("/mkdir", bodyParser.urlencoded({ extended: false }), (req, res) => { + fs.mkdirSync(path.join(__dirname, req.body.directory, req.body.name)) + + res.redirect(req.body.directory) }) } \ No newline at end of file diff --git a/resources/dashboard.html b/resources/dashboard.html index 54048f5..f2cb0f3 100644 --- a/resources/dashboard.html +++ b/resources/dashboard.html @@ -14,5 +14,13 @@ + +

Make Directory

+
+ + + + +
\ No newline at end of file