From 81b368c11c81c7c759d4abcdff455121f2e87d9a Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Mon, 14 Nov 2016 16:45:57 +0800 Subject: [PATCH] upload image to public/uploads --- .gitignore | 3 +++ app.js | 3 +++ public/uploads/.gitkeep | 0 3 files changed, 6 insertions(+) create mode 100644 public/uploads/.gitkeep diff --git a/.gitignore b/.gitignore index 9a95231c7..36c1efd87 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ public/js/config.js # ignore webpack build public/build public/views/build + +public/uploads/* +!public/uploads/.gitkeep diff --git a/app.js b/app.js index adb7f81fb..30baf1ca3 100644 --- a/app.js +++ b/app.js @@ -405,6 +405,9 @@ app.get('/me', function (req, res) { //upload to imgur app.post('/uploadimage', function (req, res) { var form = new formidable.IncomingForm(); + form.uploadDir = "public/uploads"; + form.keepExtensions = true; + form.parse(req, function (err, fields, files) { if (err || !files.image || !files.image.path) { response.errorForbidden(res); diff --git a/public/uploads/.gitkeep b/public/uploads/.gitkeep new file mode 100644 index 000000000..e69de29bb