Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I have a file upload control in my view which is working perfectly in Firefox. However, its not work proper in chrome. when i click on upload button then file dialog open every time.
Here is my View Code:
HTML
   @using (Html.BeginForm("Index", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" }))
        {
 <div class="choose-file">Choose a file to upload:</div>
<div class="input-group">
                                        <span class="input-group-btn">
                                            <span class="btn btn-primary btn-file" style="padding:4px 12px; background:#25374a; height:30px;">
                                                Browse…
                                                <input type="File" id="FileUpload" name="FileUpload" class="button5" />
                                            </span>
                                        </span>
                                        <input type="text" readonly="" style="height:30px; box-shadow:none;" class="form-control">
                                    </div>
}


And here is my Controller Code:
C#
[AcceptVerbs(HttpVerbs.Post)]      
        public ActionResult Index(HttpPostedFileBase FileUpload)
        {
 if (FileUpload.ContentLength > 0)
                {
                    string fileName = Path.GetFileName(FileUpload.FileName);
                    string path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
                    try
                    {
                        FileUpload.SaveAs(path);
                        dt = ProcessCSV(path);
                        //Process the DataTable and capture the results to our SQL Bulk copy
                        ViewBag.Message = ProcessBulkCopy(dt);
                        Session["rowcnt"] = dt.Rows.Count;
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Message = ex.Message;
                    }
                }
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900