不太好意思啊,这篇随笔有点短,因工作上需要用WCF调用有一个别的语言开发的服务接口!而涉及到图片传输的部分只让传Base64字符串。

所以下面简短的代码即可用于将客户浏览器上传过来的图片文件转换成Base64字符串

                                 //上传控件.PostedFile.InputStream
public void EncodingBase64_Image(Stream stream, ref string base64Str)
{
    using (BinaryReader binReader = new BinaryReader(stream))
    {
        byte[] bytes = binReader.ReadBytes(Convert.ToInt32(stream.Length));
        base64Str = Convert.ToBase64String(bytes);
    }
}

  结束。。

相关文章:

  • 2021-12-03
  • 2022-12-23
  • 2021-10-10
  • 2021-11-20
  • 2022-12-23
  • 2021-07-05
  • 2021-08-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案