jQuery下载文件 post(后台都写好了)

var $iframe = $('#downfile');
var $form = $('
'); $form.attr('action', './excel'); // canvas转化的图片 // var picSrc = canvas.toDataURL("image/jpeg"); $form.append($("").attr("type", "hidden").attr("name", "pic").attr("value", picSrc)); $form.append($("").attr("type", "hidden").attr("name", "filename").attr("value", fileName)); $form.append($("").attr("type", "hidden").attr("name", "rownum").attr("value", rowNum)); $form.append($("").attr("type", "hidden").attr("name", "condition").attr("value", JSON.stringify(selectInfo).replace(/\"/g, "\'"))); $form.append($("").attr("type", "hidden").attr("name", "copydata").attr("value", JSON.stringify(copyData).replace(/\"/g, "\'"))); $iframe.append($form); $form.submit(); $form.remove(); // JSON对象转化为字符串后,将双引号改为单引号 // JSON.stringify(selectInfo).replace(/\"/g, "\'")
// 图片相关处理JAVA
Base64 base64 = new Base64();
byte[] imgByte = base64.decode(picString.substring("data:image/jpeg;base64,".length()));

 

你可能感兴趣的:(JS)