前端将图片转换为base64位无法使用ajax传递怎么解决?
前端生成的代码最终格式如下:
data:image/png;base64,xxxxxxxxxx...........
后端这样解码
base64=base64.Replace("data:image/png;base64,", "");
byte[] bytes =Convert.FromBase64String(base64);
MemoryStream memStream = new MemoryStream(bytes);
BinaryFormatter binFormatter = new BinaryFormatter;
return(System.Drawing.Image)binFormatter.Deserialize(memStream);
string base64Str = "图片的BASE64字符串";
byte[] bytes = System.Convert.FromBase64String(base64Str);
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes))
{return System.Drawing.Image.FromStream(ms);}
ajax({,url : form.action,,type : "POST",,data : formData,
dataType:"text",,processData : false,,success:function(data).window.location.href="${ctx}"+data;
xhr:function//在jquery函数中直接使用ajax的XMLHttpRequest对象
var xhr = new XMLHttpRequest
xhr.upload.addEventListener