首页 > 代码库 > canvas图片base64编码后,ajax提交到后台

canvas图片base64编码后,ajax提交到后台

 

如题,直接上JS

var imgData = http://www.mamicode.com/canvas.toDataURL("image/png");var data = http://www.mamicode.com/imgData.substr(22);$.post(‘Gen‘,{ ‘data‘: data, ‘remark‘: $(‘remark‘).val() },function(success) {$(‘#img1‘).src(‘data:image/jpeg;base64,‘ + success);});

后台C#

string inputStr = data;            byte[] arr = Convert.FromBase64String(inputStr);            MemoryStream ms = new MemoryStream(arr);            Bitmap bmps = new Bitmap(ms);

然后你要怎么处理都可以了