c#如何获取到传过来的byte[]文件保存到服务器,Url保存到数据库
1个回答
展开全部
以下是服携指务器接收函数PostMember,仅供参考
[HttpPost]
public void PostMember()
{
HttpPostedFile file = null;//定义文件接收类
//如果有伍脊其他参数,下面的示例接收数据
//var openid = HttpContext.Current.Request.Form["openid"];
foreach (string item in HttpContext.Current.Request.Files)
{
file = HttpContext.Current.Request.Files[item];
}
if (file == null || openid == null)
{
throw new Exception("文件不存在");
}
string openpath = HttpContext.Current.Server.MapPath("~/video/" + openid + "/");
string fileName = DateTime.Now.ToFileTime() + ".mp3";
string sourepath = openpath + fileName;
file.SaveAs(sourepath);
//至于腔隐渗怎么把这个地址存到库里,我就不写了,因为每个人都有不同的业务逻辑
}
[HttpPost]
public void PostMember()
{
HttpPostedFile file = null;//定义文件接收类
//如果有伍脊其他参数,下面的示例接收数据
//var openid = HttpContext.Current.Request.Form["openid"];
foreach (string item in HttpContext.Current.Request.Files)
{
file = HttpContext.Current.Request.Files[item];
}
if (file == null || openid == null)
{
throw new Exception("文件不存在");
}
string openpath = HttpContext.Current.Server.MapPath("~/video/" + openid + "/");
string fileName = DateTime.Now.ToFileTime() + ".mp3";
string sourepath = openpath + fileName;
file.SaveAs(sourepath);
//至于腔隐渗怎么把这个地址存到库里,我就不写了,因为每个人都有不同的业务逻辑
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询