catch error on folder creation

This commit is contained in:
raphael 2019-01-11 10:33:32 +01:00
parent ddd7153540
commit 47e7ff18d0

View File

@ -57,8 +57,12 @@ function progressUploadFormData(formData) {
var filename = whiteboardId+"_"+date+".png"; var filename = whiteboardId+"_"+date+".png";
fs.ensureDir("./public/uploads", function(err) { fs.ensureDir("./public/uploads", function(err) {
if(err) {
console.log("Could not create upload folder!", err);
return;
}
var imagedata = fields["imagedata"]; 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,/, ""); imagedata = imagedata.replace(/^data:image\/png;base64,/, "").replace(/^data:image\/jpeg;base64,/, "");
console.log(filename, "uploaded"); console.log(filename, "uploaded");
fs.writeFile('./public/uploads/'+filename, imagedata, 'base64', function(err) { fs.writeFile('./public/uploads/'+filename, imagedata, 'base64', function(err) {