Click here to Skip to main content
15,923,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I read Articles that
Says
"PostedFile.FileName"
property of A FileUploader returns the fullpath
of the uploaded file like "c:\.."
but it keeps on returning only the File name of the uploaded file
like "test.txt"

I don't know why.

here is my code

asp:

<asp:FileUpload ID="QestionsFU" runat="server" />

C#
String filename=QestionsFU.PostedFile.FileName;
Posted

You can't - security prevents you knowing anything about the machine behind the browser.
You don't need it anyway - you cannot restore to it by download from the user as they will select where the file goes...
 
Share this answer
 
Due to security reasons most browsers (Im not 100% sure, thats why I say most) wont send the entire path, only the file name. You should never need the entire path.
 
Share this answer
 
Hi,

You should know where your application is saving files, if so getting full path name is easy,
String filename=QestionsFU.PostedFile.FileName; 

this actually returns the client filename. Meaning the path to the specified file. Supposed your app save all files under C:\UPLOADED_FILES\ in server.
then full file name will be
String filename="C:\UPLOADED_FILES\"+QestionsFU.PostedFile.FileName;

so you have the full path now.
 
Share this answer
 
Through plain browser implementations if you cant get the full file path.
you need then resort to ActiveX upload controls.
Those would give you an upload file path.
Article for Activex -

codeproject.com/KB/COM/CompleteActiveX.aspx"
Link

but its only worth if you really have the need to do that. Considering security and other design implementations.
Hope this helps.
Thanks!
 
Share this answer
 
v2

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