I am getting an error when I send base64 image in post call at server side.
我在服务器端的post post中发送base64镜像时收到错误。
I am using
我在用
var send_item = {
lottreyId: data.data.id,
title: item.title,
merchant: item_val.merchant.id,
value: item_val.value,
description: item_val.description,
image: base64
};
$http.post('/api/lottrey_item',
{
send_item
}).then(function (data)
{
console.log(data);
}, function (err)
{
console.log(err);
reject();
});
I can't use form data for send image, also, I can't use ng-file-upload
.
我不能使用表单数据发送图像,我也不能使用ng-file-upload。
When I use form data I can't get data in req.data parameter
.
当我使用表单数据时,我无法在req.data参数中获取数据。
Can I use any alternative way to save an image in a temp folder in my project directory?
我可以使用任何替代方法将图像保存在项目目录中的临时文件夹中吗?
1 个解决方案
#1
0
You should change the maximum request body size of express-bodyparser
in your /config/lib/express.js
. In the following line:
您应该在/config/lib/express.js中更改express-bodyparser的最大请求体大小。在以下行中:
app.use(bodyParser.urlencoded({
extended: true
}));
Change it to (and adjust the limit value if needed):
将其更改为(并根据需要调整限制值):
app.use(bodyParser.urlencoded({
extended: true,
limit: '50mb'
}));
I can't test right now but it should do the trick.
我现在无法测试,但它应该做的伎俩。
#1
0
You should change the maximum request body size of express-bodyparser
in your /config/lib/express.js
. In the following line:
您应该在/config/lib/express.js中更改express-bodyparser的最大请求体大小。在以下行中:
app.use(bodyParser.urlencoded({
extended: true
}));
Change it to (and adjust the limit value if needed):
将其更改为(并根据需要调整限制值):
app.use(bodyParser.urlencoded({
extended: true,
limit: '50mb'
}));
I can't test right now but it should do the trick.
我现在无法测试,但它应该做的伎俩。