Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi All

i need to upload xls file data from client side to server side sql Server
table , for that i used FileUpload control in asp.net controls, but i am not geting
file full path from client side how can i get can you please help me any one
and i need not to save that file to server side
i used these following code but still i am getting file name only but not full path
please help me

C#
string FileName = FileUpload1.FileName;
string fillPath = FileUpload1.PostedFile.FileName;


the following code also i tried but it is saving server side but i dont need to save
from server side , just i need only Path from Client Computer using C#.net Code
C#
FileUpload1.SaveAs(Server.MapPath("download/" + "NewExcel.xlsx"));



Thanks
Sudheer.N
Posted
Updated 3-Jan-12 19:10pm
v2

1 solution

C#
string filename = FileUpload1.FileName;
          
            FileUpload1.PostedFile.SaveAs(Server.MapPath("~\\Uploadform\\" + filename.Trim()));
            
          string path = "~\\Uploadform\\" + filename.Trim();
           
            SqlConnection con = new SqlConnection(str);
            cmd = new SqlCommand("Insert into Circular(date,ctype,title,type,url1) values('"+txtdate.Text+"','" + TextBox1.Text + "','" + txttitle.Text + "','" + txttype.Text + "','" + path + "' )", con);
            lblinfo.Text = " Uploaded Successfully ";
            cmd.CommandType = CommandType.Text;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
 
Share this answer
 
v2
Comments
sudheer.learner 4-Jan-12 1:41am    
i dont need to save in to Server please understand my question
i need client side path before using
FileUpload1.PostedFile.SaveAs(Server.MapPath("~\\Uploadform\\" + filename.Trim()));

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