by
0 16
0
6
3,413
2
Top 1% !
Popular
Famous
Tagged
Specified
OpenSource
Popularity: 3938th place

Published on:

.NETFramework4.5
LanguageCSharp
LicenseMIT_X11
OSWindows
TechnologyMVC

Upload File

Upload File MVC4 patterns
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/11298/Upload-File?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
Controller: public ActionResult Index() { return View(); } Model: private HttpPostedFileBase File { get; set; } #region PROPERTIES [Display(Name = "Upload your .txt File")] [FileExtensions(Extensions = "txt", ErrorMessage = "The file you selected is not a valid .txt file")] [Required(ErrorMessage = ".txt file not selected")] public HttpPostedFileBase File1 { get { return this.File; } set { this.File = value; } } #endregion Views: <div id="Componentsdiv"> @using (Html.BeginForm(<action>, <Controller>, FormMethod.Post, new { enctype = "multipart/form-data" })) { <fieldset> <legend>Upload TXT File</legend> <div class="editor-label"> <fieldset> <legend>File</legend> @Html.TextBoxFor(m => m.File1, "Select new file", new { id="firstfile", type = "file"}) @Html.ValidationMessageFor(m => m.File1) </fieldset> </div> <p> <input type="submit" id="submitbutton" hidden="hidden"/> </p> </fieldset> } </div>
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus