summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYukai Huang2016-11-14 16:45:57 +0800
committerYukai Huang2016-11-14 16:45:57 +0800
commit81b368c11c81c7c759d4abcdff455121f2e87d9a (patch)
treecd97261147a47b438ccb0ce12e1c4491aa081ec3
parenta04c6ef127f5982eec5353e1468ef881fbac03ea (diff)
upload image to public/uploads
-rw-r--r--.gitignore3
-rw-r--r--app.js3
-rw-r--r--public/uploads/.gitkeep0
3 files changed, 6 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 9a95231c..36c1efd8 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 adb7f81f..30baf1ca 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 00000000..e69de29b
--- /dev/null
+++ b/public/uploads/.gitkeep