Click here to Skip to main content
15,910,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having a fileuploader(<asp:FileUpload ID="FileUpload1" runat="server" />) control on my aspx page. On button click i want the physical fullpath of my file, which i am going to upload on server. If the file is in desktop then it should show C:\Documents and Settings\Administrator\Desktop\Book1.xlsx
Posted
Comments
Dholakiya Ankit 13-Sep-13 23:52pm    
you don't get solution?

Hi,
try this

string filePath = Path.GetFullPath(FileUpload1.FileName);;
 
Share this answer
 
v2
Comments
singh420 13-Sep-13 6:18am    
It gives only the name of the file. I need physical path of that file.
Adarsh chauhan 13-Sep-13 6:28am    
see the improved solution..
Please refer this link and check out with your question.
Here is the link below.
get full path of file using fileupload control[^]
 
Share this answer
 
try this

string s1=Path(FileUpload1.FileName);

hope this will help you
 
Share this answer
 
Comments
singh420 13-Sep-13 6:40am    
Not working.
This is not possible in any browser, as a security measure.

If this were possible, an attacker could gain information regarding how files/folders were structured on a client computer.

Why do you need this information?

You cannot get it because the browser does not send it. It would be dangerous if the browsers sent the full path at user's system.

refer this link[^]

or
http://stackoverflow.com/questions/1130560/get-full-path-of-a-file-with-fileupload-control[^

regards..:)
 
Share this answer
 
Hi...
See this. Here images are saved in imagefolder of project and its url('~/imagefolder/imagename.jpg') saved in databse like.
imgful=fileupload control.
C#
//Get Filename from fileupload control
                string filename = Path.GetFileName(imgful.PostedFile.FileName);
                //Save images into Images folder
                imgful.SaveAs(Server.MapPath("~/Images/" + filename));
                //Open the database connection
                con = new MySqlConnection(cs);
                con.Open();
                //Query to insert images path and name into database

C#
cmd = new MySqlCommand("Insert into Items(ProductName,ImageUrl) values(@ImageName,@ImagePath)", con);

                        //Passing parameters to query
                        cmd.Parameters.AddWithValue("@ImageName", filename);
                        cmd.Parameters.AddWithValue("@ImagePath", "~/Images/" + filename);
                        con.Open();
                        cmd.ExecuteNonQuery();
                        //Close dbconnection
                        con.Close();

Thank u.
 
Share this answer
 

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