Added ecstatica generator, file uploader and user tools

This commit is contained in:
2019-11-02 04:58:00 +05:30
parent 7440c26a5c
commit fb10774af5
67 changed files with 2284 additions and 255 deletions

21
server/upload/upload.js Normal file
View File

@@ -0,0 +1,21 @@
const IncomingForm = require('formidable').IncomingForm
const fs = require('fs')
var path = require('path');
module.exports = function upload(req, res) {
var form = new IncomingForm()
form.on('file', (field, file) => {
var oldpath = file.path;
// var newpath = __dirname + file.name;
var newpath = path.join(__dirname, '..', 'image_uploads', file.name);
fs.rename(oldpath, newpath, function (err) {
if (err) throw err;
res.write('File uploaded and moved!');
res.end();
});
})
form.on('end', () => {
res.json()
})
form.parse(req)
}