文件上传
public ActionResult UpLoad(System.Web.HttpPostedFileWrapper imgPath)
{
var IsSusseiss = false;
var result = "";
if (imgPath != null)
{
string temp_path = "Equ_BasisInfo/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/";
string path = Server.MapPath("/UpLoad/") + temp_path;
//验证这个路径得文件加是否存在
if (!System.IO.Directory.Exists(path))
{
//创建这个路径下得文件夹
System.IO.Directory.CreateDirectory(path);
}
string picName = imgPath.FileName;
picName = picName.Replace(picName.Split('.')[0], DateTime.Now.ToString("yyyyMMddHHmmssms"));
string allPath = path + picName;
//验证这个路径下文件是否存在
if (!System.IO.File.Exists(allPath))
{
imgPath.SaveAs(allPath);
result = temp_path + picName;
IsSusseiss = true;
}
}
return Json(new { data = result, IsSuccess = IsSusseiss }, "text/html", JsonRequestBehavior.AllowGet);
}