In monorail, file upload is simple. You can directly use the httppostedfile class after using the smart binding method.
VM file:
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
Pay special attention to the simhei part.
Controller file: Public Void Upload (httppostedfile additionalfile)
{
Additionalfile. saveas ( " C :\\ " + Additionalfile. filename. substring (additionalfile. filename. lastindexof ( " \\ " ) + 1 ));
This . Cancelview ();
}
Smart binding is used.
Note: This controller class must be inherited from smartdispatchercontroller
Of course, replace the fourth line of the VM file:<InputType= FileName= "Additionalfile" />
Yes, too.