From 47e7ff18d0daa85a8c7cbaf4885907c86c68fe35 Mon Sep 17 00:00:00 2001 From: raphael Date: Fri, 11 Jan 2019 10:33:32 +0100 Subject: [PATCH] catch error on folder creation --- server.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index e17f809..6948873 100644 --- a/server.js +++ b/server.js @@ -57,8 +57,12 @@ function progressUploadFormData(formData) { var filename = whiteboardId+"_"+date+".png"; fs.ensureDir("./public/uploads", function(err) { + if(err) { + console.log("Could not create upload folder!", err); + return; + } var imagedata = fields["imagedata"]; - if(imagedata && imagedata != "") { //Save from base64 + if(imagedata && imagedata != "") { //Save from base64 data imagedata = imagedata.replace(/^data:image\/png;base64,/, "").replace(/^data:image\/jpeg;base64,/, ""); console.log(filename, "uploaded"); fs.writeFile('./public/uploads/'+filename, imagedata, 'base64', function(err) {