You must Sign In to post a response.
  • Category: ASP.Net MVC

    Error code212 while uploading a file in MVC

    Hi Team

    Greetings of the day..

    I am getting an error while uploading a file. I am using vs2013 and JS and KnockoutJs.

    Please find the attachment

    Give some suggessions...
  • #762614
    hi, Prathi,
    there is not a issue whether u are using vs2010 or vs2012 or vs2013.First put a breakpoint check each and every line carefully, you can find the error or problem.
    Example code:
    string path = Server.MapPath("~/");
    string phy_path = "";
    string FileUpload1_path = "";
    string File1="";
    string FileType = FileUpload1.PostedFile.ContentType;
    if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
    FileUpload1_path = "UploadFiles/" + FileUpload1.PostedFile.FileName + getExtension(FileUpload1.FileName);
    File1 = phy_path + "UploadFiles/" + FileUpload1.PostedFile.FileName + getExtension(FileUpload1.FileName);
    FileUpload1.SaveAs(path + FileUpload1_path);
    string ext2 = Path.GetExtension(File1);
    string type = String.Empty;
    string extenfile = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);
    string extimage = System.IO.Path.GetExtension(FileUpload2.PostedFile.FileName);
    if (extenfile.ToLower().Trim() == ".pdf" || extenfile.ToLower().Trim() == ".xlsx" || extenfile.ToLower().Trim() == ".xls" || extenfile.ToLower().Trim() == ".doc")
    OleDbConnection con = Connection.DBconnection();
    OleDbCommand com = new OleDbCommand("insert into tbl_enquiry(photo)values(@photos); com.Parameters.AddWithValue("@attachedfile", SqlDbType.VarChar).Value = File1.ToString();

    else refer below links:

    hope this information help you
    Regards with

  • #762625
    Hi Nagaraju,

    Can you please share your error details, so that we will help you better.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

Sign In to post your comments