vm文件:
1<h1 align="center">Upload photo</h1>
2<form action="upload.rails" method="post" enctype="multipart/form-data">
3
4$FormHelper.FileField("additionalFile")
5<input name="act" type="submit" value="Upload">
6</form>
7
特别注意其中黑体的部分2<form action="upload.rails" method="post" enctype="multipart/form-data">
3
4$FormHelper.FileField("additionalFile")
5<input name="act" type="submit" value="Upload">
6</form>
7
Controller文件:
public void upload(HttpPostedFile additionalFile)
{
additionalFile.SaveAs("c:\\" + additionalFile.FileName.Substring(additionalFile.FileName.LastIndexOf("\\") + 1));
this.CancelView();
}
使用的是智能绑定的方式{
additionalFile.SaveAs("c:\\" + additionalFile.FileName.Substring(additionalFile.FileName.LastIndexOf("\\") + 1));
this.CancelView();
}
注意:此Controller类需要从SmartDispatcherController继承
当然将vm文件的第四行换成:
<input type=file name="additionalFile" />
也是可以的
本文转自永春博客园博客,原文链接:http://www.cnblogs.com/firstyi/archive/2007/11/03/947945.html,如需转载请自行联系原作者