我想用 base64
对接收到的图像进行编码 HttpPostedFileBase
以将其发送到 json 对象中,但我不知道该怎么做。 .请告诉我如何将它解码回 HttpPostedFileBase
最佳答案
我试过了,成功了
string theFileName = Path.GetFileName(YourFile.FileName);
byte[] thePictureAsBytes = new byte[YourFile.ContentLength];
using (BinaryReader theReader = new BinaryReader(YourFile.InputStream))
{
thePictureAsBytes = theReader.ReadBytes(YourFile.ContentLength);
}
string thePictureDataAsString = Convert.ToBase64String(thePictureAsBytes);
关于c# - base64 编码 HttpPostedFileBase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31313280/