From 4f8deb7896cecd9b6417d8dcb45416a7d8b07caa Mon Sep 17 00:00:00 2001 From: istemi-bahceci Date: Fri, 17 Mar 2017 18:48:18 +0300 Subject: [PATCH] Hotfix for error in server while loading pathways --- app.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app.js b/app.js index 98bbbca3..03658c51 100644 --- a/app.js +++ b/app.js @@ -37,20 +37,23 @@ function indexGetHandler(req,res){ ********************************/ function loadGraphHandler(req, res) { - fs.readFile(req.file.path, {encoding: 'utf-8'}, function(err,data) + if(req.file) { - if (!err) + fs.readFile(req.file.path, {encoding: 'utf-8'}, function(err,data) { - res.writeHead(200, {'Content-Type': 'multipart/form-data'}); - res.write(data); - res.end(); - } - else - { - console.log(err); - } - fs.unlinkSync(req.file.path); - }); + if (!err) + { + res.writeHead(200, {'Content-Type': 'multipart/form-data'}); + res.write(data); + res.end(); + } + else + { + console.log(err); + } + fs.unlinkSync(req.file.path); + }); + } } function loadSampleFile(req, res)