文件上传
string path = Server.MapPath("~/Content/img/");//设定上传的文件路径
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
//判断是否已经选择上传文件
HttpPostedFileBase file = Request.Files["file"];
string filenName = file.FileName;
string filepath = path + filenName;
file.SaveAs(filepath);//上传路径
//然后你就可以用filepath新增到数据库里面了。
return Content("");

浙公网安备 33010602011771号