我在Ubuntu上有node.js项目。我有能力将图片上传到服务器。当我从node bin/www
启动服务器时,一切正常。但是,当我尝试从Forever启动时,服务器正在运行,但图片未上传。在
var/log/myapp.log
没有错误。我用:
编辑:这是代码文件条目:
function decodeBase64Image(dataString) {
var matches = dataString.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/),
response = {};
if (matches.length !== 3) {
return new Error('Invalid input string');
}
response.type = matches[1];
response.data = new Buffer(matches[2], 'base64');
return response;
}
var login = req.session.login;
var time = Date.now();
originalName = login + time + '.png';
var target_path = 'public/uploads/' + originalName;
var imageBuffer = decodeBase64Image(photo);
fs.writeFileSync(target_path, imageBuffer.data);