Abd*_*lah 5 c# asp.net-mvc json web-services http
我想base64编码一个正在接收的图像,HttpPostedFileBase以便在json对象中发送它,我不知道它是如何完成的......请告诉我如何将其解码回HttpPostedFileBase
Abd*_*lah 13
我试过这个并且它有效
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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8908 次 |
| 最近记录: |