52,782
社区成员
发帖
与我相关
我的任务
分享对于ajax,我是菜鸟,在开发发中应到用以下代码,谁能帮解释下是什么意思,希望能得到指导。
最后一步,在控制器里,添加一个删除文件的action
先在控件器里面添加命名空间System.IO;
然后添加action
public ActionResult delImg(string url)
{
if (Request.IsAjaxRequest())
{
FileInfo file = new FileInfo(Server.MapPath(url));
if (file.Exists)
{
file.Delete();
return Content("1");
}
else
return Content("-1");
}
else
return Content("-1");
}