This commit is contained in:
bingus_violet 2024-01-16 21:04:50 +00:00
parent 05624aaf9a
commit 78696fa7db
2 changed files with 27 additions and 8 deletions

View file

@ -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)
})
}

View file

@ -14,5 +14,13 @@
<input type="file" name="file">
<input type="submit">
</form>
<h2>Make Directory</h2>
<form action="./mkdir" method="post">
<input type="text" readonly value="{DIRECTORY}" name="directory">
<input type="password" placeholder="Password" name="password">
<input type="text" name="name" placeholder="folderName">
<input type="submit">
</form>
</body>
</html>