1.前台调用
$("#form1").ajaxSubmit({
type:"post",
url:"/AdminNewList/FileUpload",
success:function(data){
var serverData=data.split(':');
if(serverData[0]=="ok")
{
$('#showImage').Append("<image src='"+serverData[1]+"' width='40px' height='40px'/>"));
}
}
});
2.
public ActionResult FileUpload()
{
HttpPostedFileBase postFile=Request.Files["fileUp"];
if(postFile==null)
{
return Content("no:请上传文件")
}
else
{
string fileName=Page.GetFIleName(postFile.FileName);
string fileExt=Path.GetExtension(fileName);
if(fileExt==".jpg")
{
string dir="/ImagePath/"+DateTime.Now.Year+"/"+DateTime.Now.Month+"/";
Directory.CreateDirectory(Path.GetDirectoryName(Request.MapPath(dir)));
//用文件流的MD5来保存
postFile.Save();//路径加上
}
}
}
3获取子窗体的window对象
var win=$('#AddFrame')[0].contentWindow;
4.子窗体调用父窗体中的方法
window.parent.afterAdd();
5过滤器中的方法
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
action 过滤器
}
用这个就可以完成一个统一的校验了
}