public string Upload(string Bytes)
{
try
{
byte[] bytes = Convert.FromBase64String(Bytes);
string times = DateTime.Now.ToString("yyyy-MM-dd");
//建立存储的目录
string ImageFileUrl = "Myfiles/" + times + "/";
//判断目录是否存在
if (!Directory.Exists(Server.MapPath(ImageFileUrl)))
{
//如果不存在,创建
Directory.CreateDirectory(Server.MapPath(ImageFileUrl));
}
string NewFilethumbName = Guid.NewGuid().ToString() + ".pdf"; //图片命名
string ImageFile = "/allapi/" + ImageFileUrl + NewFilethumbName; //返回路径
if (bytes != null)
{
using (System.IO.MemoryStream mem = new MemoryStream(bytes))
{
string NewFileJpg = Server.MapPath("~/allapi/" + ImageFileUrl) + NewFilethumbName; //保存路径
C# MVC 文件字节流 保存
最新推荐文章于 2024-05-22 10:46:24 发布