简体   繁体   English

将base64格式的文件从Java脚本上传到Java

[英]upload base64 format file from java script to java

I want to upload Base64 image to server . 我想将Base64映像上传到服务器。 I am using jsp and js as front end client side and java as back end . 我使用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")
        }
    });

If i upload from this i am getting below error 如果我从此上传,我将出现以下错误

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 ......

Please somebody help me as i have stuck up with this from several hours. 请有人帮我,因为我已经从几个小时内坚持了下来。

You cannot put a huge parameter into the URL. 您不能在URL中输入巨大的参数。

Put all the parameters, or at least the imgData into the request body only. 仅将所有参数或至少将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")
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM