Hi,
I want to Open Folder Dialog box in MVC web application in Controller code.
please help.
Thanks
Hi,
I want to Open Folder Dialog box in MVC web application in Controller code.
please help.
Thanks
Hi @KIRANKUMARGUNTI-3906 ,
Do you means fileupload? You could use Fileupload control.
@Html.EditorFor(model => model.ImagePath, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ImagePath, "", new { @class = "text-danger" })
@using(Html.BeginForm("ContactForm", "Home", FormMethod.Post, new
{
enctype = "multipart/form-data"
}))
[HttpPost]
public ActionResult ContactForm(MemberModel membervalues)
{
//Use Namespace called : System.IO
string FileName = Path.GetFileNameWithoutExtension(membervalues.ImageFile.FileName);
//To Get File Extension
string FileExtension = Path.GetExtension(membervalues.ImageFile.FileName);
//Add Current Date To Attached File Name
FileName = DateTime.Now.ToString("yyyyMMdd")+"-"+FileName.Trim()+ FileExtension;
//Get Upload path from Web.Config file AppSettings.
string UploadPath = ConfigurationManager.AppSettings["UserImagePath"].ToString();
//Its Create complete path to store in server.
membervalues.ImagePath = UploadPath + FileName;
//To copy and save file into server.
membervalues.ImageFile.SaveAs(membervalues.ImagePath);
return View();
}
More details,you could refer to below article:
https://www.c-sharpcorner.com/article/asp-net-mvc-form-with-file-upload/
Best regards,
Yijing Sun
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
3 people are following this question.