I have a asp.net page with the following on the page:

<asp:FileUpLoad id="FileUpLoad1" runat="server" /><br />

but i need to get the pathname in that textbox to use with a stored procedure. Now the only thing i can get is the filename (not the path). Any ideas?

This is my code retrieving the filename:

string filename = FileUpLoad1.FileName.ToString();
            //string filepath = FileUpLoad1.;
            Label1.Text = filepath + filename;
            //DataAccess.UploadFlatFile(filepath , filename);

:-/

any suggestions will be much appreciated

just use:

string filepath = System.IO.Path.GetFullPath(FileUpLoad1.FileName);

:icon_mrgreen:

just use:

string filepath = System.IO.Path.GetFullPath(FileUpLoad1.FileName);

Alternatively you can use:

Fileupload1.PostedFile.FileName;

remember to mark the thread as solved if you have found an answer :)

this still doesnt work, as it only returns this

C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\upload1.txt

instead of the actual path where it was on the client side....

works perfetly for me : /
Can you post the rest of the code you used when trying it?

which code would you need? lol as not being specific doesnt help me on what code to paste

Well basically that all i have:

string filepath = "\'" + System.IO.Path.GetFullPath(FileUpLoad1.FileName)

The thing is in the FileUpload1 textbox it shows the correct path but when put in lable with above code it shows:
C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\upload1.txt

so i don't know why it's doing that?

have you tried it with the code i posted?
I made a simple page with a FileUpload, a button and a label,
when i click the button it runs Label1.Text = Fileupload1.PostedFile.FileName; and it displays the full path and filename correctly.

All i get in the lable is : upload1.txt..... not the full path(if i run your code)...weird!

It works only on old browser IE. Latest browsers do not reveal full path for security reasons. However, I'm sure there is a way out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.