From 22cf43731ccae151b1fddc80a47b30b8f943a481 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Tue, 5 Nov 2019 01:20:56 +0000 Subject: Fix uploading, uses full path now --- src/server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/server.js') diff --git a/src/server.js b/src/server.js index a735d35..1bbac30 100644 --- a/src/server.js +++ b/src/server.js @@ -4,13 +4,14 @@ const cookieParser = require('cookie-parser'); const request = require('request'); const crypto = require('crypto'); const uuidv4 = require('uuid/v4'); +const path = require('path'); const Op = require('sequelize').Op; const multer = require('multer'); var storage = multer.diskStorage({ destination: function (req, file, cb) { - cb(null, 'src/uploads/') + cb(null, __dirname+'/uploads/') }, filename: function (req, file, cb) { var ext = ""; @@ -160,7 +161,7 @@ function setUpRoutes(models, jwtFunctions, database) { try { const type = req.body.type const newPost = await models.posts.create(req.body); - req.files.forEach(async (file) => { + req.files.forEach(async (file) => { await models.pictures.create({ "source": "uploads/" + file.filename, "postId": newPost.id }); console.log("uploaded ", file.path); }) -- cgit v1.2.3