1

i am using a asyncfileupload control to upload a file in a folder in hosted server and trying to read that file and store data in database .... here's what i am doing:

this the asyncfilupload control:

<asp:AsyncFileUpload ID="venfileupld" runat="server" 
  OnUploadedComplete="ProcessUpload" FailedValidation="False" />

and this is what i am doing in my .cs file :

    protected void ProcessUpload(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {

        string name = System.IO.Path.GetFileName(e.FileName);
        string dir = Server.MapPath("upload_excel/");
        string path = Path.Combine(dir, name);
        venfileupld.SaveAs(path);
        writetodb(path);


    }

here writetodb is the function which is taking the file as argument and reading it and saving it ...

now this is working fine in my localhost but when i hosted it in a hosting server then its not working ... in my hosted server i can see that the file is getting uploaded there but i thing i am not getting the exact path of the file to read ... so i am getting an error ...

so what to do now? any help

UPDATE:-

this is the writetodb(path) function:

public void writetodb(string filename)
    {
        string[] str;
        string vcode = "";
        string pswd = "";
        string vname = "";
        StreamReader sr = new StreamReader(filename);
        string line = "";

        sr.ReadLine();
        while ((line = sr.ReadLine()) != null)
        {
            str = line.Split(new char[] { ',' });
            if (str[0] != "")
            {
                vcode = str[0];
                pswd = str[1];
                vname = str[2];
                insertdataintosql(vcode, pswd, vname);
            }
        }
        fetch4();
        lblmsg4.Text = "Data Inserted Sucessfully";
    }

and the error i am getting is : "Unknown Server Error"

any one pls i am really stuck

Arindam Das
  • 699
  • 4
  • 20
  • 39

0 Answers0