前端代码:
var photo = canvas.toDataURL(‘image/jpeg‘); $.ajax({ method: ‘POST‘, url: ‘httphandler‘, data: { photo: photo } });
后台代码:
var bytes = Convert.FromBase64String("base64 Content"); using (var imageFile = new FileStream("filePath", FileMode.Create)) { imageFile.Write(bytes ,0, bytes.Length); imageFile.Flush(); } return File(bytes, "image/jpeg", "test.jpg");
另外遇到一个asp.net core 编译错误:
(The "Nullable" parameter is not supported by the "Csc" task)
错误 MSB4064 “Csc”任务不支持“Nullable”参数。请确认该参数存在于此任务中,并且是可设置的公共实例属性。
C:\Program
Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.Compilation.targets
156
解决方法:
通过nuget 安装 Microsoft.Net.Compilers 包
服务器后台 保存echarts highchart 等的canvas图片
原文:https://www.cnblogs.com/worksmart/p/11423376.html