fixed image upload, delete temp file if there is error

This commit is contained in:
Baris Usakli
2013-09-09 14:29:40 -04:00
parent b24196be36
commit a1c9685b49
2 changed files with 3 additions and 2 deletions

View File

@@ -152,7 +152,7 @@ var user = require('./../user.js'),
}
var filename = uid + '-profileimg' + extension;
var uploadPath = path.join(__dirname, '../', global.nconf.get('upload_path'), filename);
var uploadPath = path.join(process.cwd(), global.nconf.get('upload_path'), filename);
winston.info('Attempting upload to: '+ uploadPath);
@@ -179,10 +179,10 @@ var user = require('./../user.js'),
res.json({ path: imageUrl });
});
});
os.on('error', function(err) {
fs.unlinkSync(tempPath);
winston.error('[%d] %s', Date.now(), + err);
});