1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| const formidable = require("formidable");
const {join} = require("path")
const path = require("path"); const fs = require("fs"); const app =express; app.post("/fils",(req,res)=>{ let form =new formidable.IncomingFrom(); form.uploadDir = join(__dirname,"/upload"); form.parse(req,(err,fields,files)=>{ let extname = path.extname(files.shipin.name) let shiponPath = files.shipin.path; fs.rename(shiponPath,shiponPath+extname,()=>{ res.send("ok") })
}) }) app.listen(3000)
|