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 過濾器
}
用這個就可以完成一個統一的校驗了
}