Click here to Skip to main content
15,995,305 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Sir

I want to know the full path of file from where file is uploaded to fileupload control.

Regards

Jaspreet Singh
Posted

Unfortunately you can't get full path of a client's system on newer browsers.

The client system's directory structure is irrelevant to any web server and thus this feature has been withdrawn in newer browsers.

You may try -
C#
FileUpload1.PostedFile.FileName;

But as I said, this will only work in older browsers like IE 5.5. I think even IE6 doesn't support revealing full path.

I was just curios why do you want a full path of a client's machine? Are you working on an interanet application?
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Apr-11 13:43pm    
I agree. I guess you understand the "from where file is uploaded" correctly -- the client part.
I would add: having no knowledge on the file path of the client part is good thing. It should not be known to the server.
My 5.
--SA
Ankur\m/ 6-Apr-11 0:21am    
Thanks!

And AFAIK it doesn't work on a localhost too on newer browsers unlike the other guy said below.
you can check it by GetFullPath method. take a look how

C#
if (FileUpload1.HasFile)
{
    string filepath = Path.GetFullPath(FileUpload1.FileName); //Returns absolute path for specified file by fileupload control.
    Label1.Text = filepath;
}
else
{
    Label1.Text = "No uploaded file";
}

Note:- Path is a class which resides in System.IO namespace. so don't forget to mention it before using command.
 
Share this answer
 
Comments
Ankur\m/ 5-Apr-11 9:43am    
That's a wrong answer. Web application works on a client server architecture. Using Path class in a server for getting client's full path will not work.
See my answer.
RaviRanjanKr 5-Apr-11 10:10am    
I've just given idea to OP how to get full path! its work on localhost that's why I've posted here. By the way thanks for your suggestion :)
Sergey Alexandrovich Kryukov 5-Apr-11 13:44pm    
Here is the thing: local host in not client part. Ankur is right.
--SA
Ankur\m/ 6-Apr-11 0:22am    
Which browser did you use? It won't work on localhost as well. Try Firefox 3.6+ or IE7+ or Chrome.
You must have tested it on IE6 or below.

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