18 lines
356 B
JavaScript
18 lines
356 B
JavaScript
|
let router = require("express").Router();
|
||
|
let isAuth = require("../user").isAuth;
|
||
|
let fs = require("fs");
|
||
|
|
||
|
|
||
|
router.get("/:name", isAuth, (req, res, next) => {
|
||
|
if ("name" in req.params && fs.existsSync("./images/"+req.params.name)) {
|
||
|
fs.unlinkSync("./images/"+req.params.name);
|
||
|
res.redirect("/");
|
||
|
} else {
|
||
|
next();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
|
||
|
module.exports = router;
|
||
|
|