Write in front
Recently started busy, the schedule is tight compared to rush, but also tomorrow to go to the driving school, can only a function of a function of the added, perhaps each completion of the function does not count what, and so will be implemented, and then find a good point of the UI to the front-end refactoring.
Series Articles
[Ef]vs15+ef6+mysql Code First mode
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (1)
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (2)--User Registration
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (3)--Verification code
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (4)--Upload Avatar
Example
Here's how to upload files in the simplest form. Of course you can use plugins or something.
@using (Html.BeginForm ("Register","UserInfo", FormMethod.Post,New{enctype ="Multipart/form-data"}) {@Html. AntiForgeryToken ()<divclass="Form-horizontal"> @Html. ValidationSummary (true) <divclass="Form-group">@Html. Labelfor (Model= Model. Header,New{@class ="Control-label col-md-2" }) <divclass="col-md-10"> <input type="file"accept="image/*"Name="name"Value=""/> </div> </div> <divclass="Form-group"> <labelclass="Control-label col-md-2"> Verification Code </label> <divclass="col-md-10"> <input type="text"Name="name"Value=" "/> "Imgcode"style="Cursor:pointer;"title="switch to the next one"Src="/userinfo/verifycodeimage"alt="Verification Code"/> </div> </div> <divclass="Form-group"> <divclass="col-md-offset-2 col-md-10"> <input type="Submit"Value="Create" class="btn Btn-default"/> </div> </div> </div>}<div>@Html. ActionLink ("Back to List","Users")</div>
Controller
[HttpPost] Publicactionresult Register (UserInfo UserInfo) {intSavecount =0; if(modelstate.isvalid) {varFiles =Request.Files; if(Files. Count >0) { varFile = files[0]; stringStrfilesavepath = Request.mappath ("~/content/images"); stringStrfileextention =path.getextension (file. FileName); if(!directory.exists (Strfilesavepath)) {directory.createdirectory (Strfilesavepath); } file. SaveAs (Strfilesavepath+"/"+ Userinfo.displayname +strfileextention); Userinfo.header="/content/images/"+ Userinfo.displayname +strfileextention; } _userinfoservicerepository.add (UserInfo); Savecount=_userinfoservicerepository.savechanges (); } if(Savecount >0) { returnRedirecttoaction ("Users"); } Else { returnView (UserInfo); } }
Results
Summarize
Using native submission forms is the simplest way, in fact, if the mobile phone browser does not support Flash or HTML5, this is the most appropriate way.
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (4)--Upload Avatar