【发布时间】:2014-02-01 09:08:36
【问题描述】:
我在 html5 移动客户端上将图像转换为 base64 并将字符串发布到我的 webapi 服务。我尝试将接收到的字符串转换回图像,但出现以下异常
输入不是有效的 Base-64 字符串,因为它包含非 base 64 字符、两个以上的填充字符或非法字符 在填充字符之间。
Pastebin of base64 string is here.
我已阅读有关替换错误字符的所有建议,因此我将这个函数写入并首先将我的字符串传递给它,但没有运气。
private string FixBase64ForImage(string Image)
{
System.Text.StringBuilder sbText = new System.Text.StringBuilder(Image, Image.Length);
sbText.Replace("\r\n", String.Empty);
sbText.Replace(" ", String.Empty);
sbText.Replace('-', '+');
sbText.Replace('_', '/');
sbText.Replace(@"\/", "/");
return sbText.ToString();
}
有没有办法确切知道是什么字符导致转换失败?
【问题讨论】: