Upload Selected File With Form Data In ASP.Net MVC - ASPsnippets
Có thể bạn quan tâm
hello,
if i remove file upload control the insert works but with file upload control insert is not working
what i want to achieve is user can type all the values in text box select image thru file upload and image save in UPLOAD folder and path of file add in data base myfile column
please advice
strongly type model create form
@model BussinessObject.UserBO @{ ViewBag.Title = "Create"; } <h2>Create</h2> @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div class="form-horizontal"> <h4>UserBO</h4> <hr /> @Html.ValidationSummary(true, "", new { @class = "text-danger" }) <div class="form-group"> @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.Address, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Address, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Address, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.EmailID, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.EmailID, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.EmailID, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.Mobilenumber, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Mobilenumber, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Mobilenumber, "", new { @class = "text-danger" }) </div> </div> <span>Select File:</span> @Html.TextBoxFor(m => m.MyFile, new { type = "file" }) <br /> @Html.ValidationMessageFor(m => m.MyFile, "", new { @class = "error" }) <hr /> <div class="form-group"> <div class="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", "Index") </div> public ActionResult Create([Bind(Include = "userid,Name,Address,EmailID,Mobilenumber, MyFile")] UserBO userBO, HttpPostedFileBase postedFile) { if (ModelState.IsValid) { //Extract Image File Name. string fileName = System.IO.Path.GetFileName(postedFile.FileName); //Set the Image File Path. string filePath = "~/Uploads/" + fileName; //Save the Image File in Folder. postedFile.SaveAs(Server.MapPath(filePath)); userbl.SaveUserregisrationBL(userBO); //db.UserBOes.Add(userBO); //db.SaveChanges(); return RedirectToAction("Index"); } return View(userBO); }Từ khóa » Html.editorfor Image Upload
-
C# - @Html.EditorFor (Image) - Stack Overflow
-
How To Create EditorFor FileUpload In Mvc 4 Razor?
-
How To Upload Image In Edit And Create View? (ASP.Net MVC) - MSDN
-
ASP.NET MVC Form With File Upload - C# Corner
-
EditorFor Image Browser Is Encoding Image Url - Telerik
-
C# - Uploading Image In ASP.NET MVC
-
How To Upload Image In Mvc Using Model - Tech Altum Tutorial
-
Can Editorfor Be Used To Create Input Type File
-
Image Upload On ASP.NET MVC With TinyMCE - İsmail Erdem Sırma
-
Image Upload Processing - ASP.NET MVC HTML Content Editor
-
Html.editorfor 文件,c# - Stack Overflow-爱代码爱编程 - 爱代码爱编程
-
C# – File Upload ASP.NET MVC - ITecNote
-
Asp.Net MVC File Upload/Update ( Both Image And .Pdf Etc ) With ...
-
I Got A Problem Making A Image Upload To Members To Edit