0
캔버스 이미지를 업로드하고 webapi를 사용하는 서버에 .png 파일로 저장하려고합니다.캔버스 이미지를 서버에 업로드하고 파일로 저장
나는 dataurl을 문자열로 서버에 업로드하는 방법을 알아 냈습니다. 나는 그것으로부터 byte []를 만들려고 시도했지만, 페인트로 파일을 열면 파일이 손상되었다는 것을 알 수있다.
client:
var dataURL = canvas.toDataURL('image/png');
Server:
string strData = postParam.dataURL.Substring("data:image/png;base64,".Length);
List<byte> src = new List<byte>();
for (int i = 0; i < strData.Length; i++)
{
char c = strData[i];
byte b = Convert.ToByte(c);
src.Add(b);
}
System.IO.FileStream fs = System.IO.File.Create(@"D:\git\Lens\Lens.Server.UI.HTML5\reports\chartImages\hello.png", 100000, System.IO.FileOptions.None);
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs);
bw.Write(src.ToArray());
그래서 내 질문은, 이미지 데이터 소스 PNG 파일에 저장하는 경우에도 옳은 일의 바이트 []입니다 생각 또는 뭔가 다른 작업을 수행 할. 그렇다면 그렇다면 내가 너무 엉망이 될 수도 내 문자열을 올바르게 변환해야합니다.