62,041
社区成员
发帖
与我相关
我的任务
分享
<input type="file" id="fileImage" name="fileImage" />
<input type="submit" value="Upload" />
public ActionResult Index()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(FormCollection collection)
{
if (Request.Files.Count == 0)
{
return View();
}
var c = Request.Files[0];
if (c != null && c.ContentLength > 0)
{
int lastSlashIndex = c.FileName.LastIndexOf("\\");
string fileName = c.FileName.Substring(lastSlashIndex + 1, c.FileName.Length - lastSlashIndex - 1);
fileName = Path.Combine(CommonUtility.DocImagePath, fileName);
c.SaveAs(fileName);
}
return View();
}