2017-09-06 63 views
0

我收到一個錯誤,當我在服務器端發送後調用base64圖像。越來越錯誤:請求實體太大的錯誤,當我發送base64圖像中意味着js

我使用

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(); 
}); 

我不能使用表單數據發送圖像,另外,我無法使用ng-file-upload

當我使用表單數據時,我無法獲取req.data parameter中的數據。

我可以使用其他方法將圖像保存在我的項目目錄中的臨時文件夾中嗎?

enter image description here

回答

0

你應該在你/config/lib/express.js改變express-bodyparser最大請求的車身尺寸。在下面一行:

app.use(bodyParser.urlencoded({ 
    extended: true 
})); 

其更改爲(如果需要調整限值):

app.use(bodyParser.urlencoded({ 
    extended: true, 
    limit: '50mb' 
})); 

我現在不能測試,但它應該做的伎倆。

+0

無法正常工作而獲得相同的錯誤。 你知道什麼時候請求是表單數據,那麼爲什麼我不在服務器端獲取數據? 在同一個項目中其他模塊可以很好地處理表單數據,我創建了一個新模塊,它不能處理表單數據 – Paras

相關問題