我想将Base64图像上传到服务器。我使用jsp和js作为前端客户端,java作为后端。
var imgData =imagesScanned.data;
JSON.stringify(imgData)
var fileShareDetails = {
pageMode : "SCAN_FILE_UPLOAD",
imgData:imgData,
};
var d = $.param(fileShareDetails);
$.ajax({
url: "folderNavigation.do?" + d,
dataType: 'JSON',
data: imgData,
type: 'POST',
success: function(data) {
alert("response is coming")
}
});
如果我从此上传,我将收到以下错误
Failed to load resource: net::ERR_CONNECTION_RESET http://localhost:9080/Initial/folderNavigation.do?pageMode=SCAN_FILE_UPLOAD…2FWi4XFMrY7Ukb5dqDgj7o%2FWo0VYySowSeckn%2BdK4XJmetKsdnNbFJkn%2F%2F2Q%3D%3 ......
请有人帮助我,因为我已经坚持了好几个小时。
答案 0 :(得分:0)
您不能在网址中加入大量参数。
将所有参数或至少imgData
放入请求正文中。
$.ajax({
url: "folderNavigation.do?" + d, // remove the "+d"
dataType: 'JSON',
data: imgData, // this part goes into the body,
// maybe you want "fileShareDetails"
// instead of "imgData"
type: 'POST',
success: function(data) {
alert("response is coming")
}
});