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 = "http://www.sunrelic.com/Default.aspx";
    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:

    http://googleweblight.com/?lite_url=http://www.aspsnippets.com/Articles/Upload-multiple-files-with-ASPNet-45-FileUpload-control-in-Visual-Studio-2012-and-2013.aspx&ei=ILvompwn&lc=en-IN&geid=7&s=1&m=189&ts=1443596805&sig=APONPFnirHZLPC1n0tmW2-Bs-pvoyOmonA

    hope this information help you
    Regards with
    Paul.S

  • #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.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments