邏輯大致是將base64字串轉成byte陣列再轉成stream存起來
string x = files.Replace("data:image/png;base64,", ""); // Convert Base64 String to byte[] byte[] imageBytes = Convert.FromBase64String(x); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); // Convert byte[] to Image ms.Write(imageBytes, 0, imageBytes.Length); System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true); image.Save(fileMapPath, System.Drawing.Imaging.ImageFormat.Png);
沒有留言:
張貼留言