Folders!
This commit is contained in:
parent
05624aaf9a
commit
78696fa7db
2 changed files with 27 additions and 8 deletions
27
index.js
27
index.js
|
@ -71,15 +71,26 @@ app.get("/", (req, res) => {
|
||||||
res.redirect("/b")
|
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) {
|
if (passwd) {
|
||||||
app.get("/dashboard.html", (req, res) => {
|
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)
|
||||||
})
|
})
|
||||||
}
|
}
|
|
@ -14,5 +14,13 @@
|
||||||
<input type="file" name="file">
|
<input type="file" name="file">
|
||||||
<input type="submit">
|
<input type="submit">
|
||||||
</form>
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in a new issue