1

I am using Fileupload control to upload file. I am displaying the selected file icon(with achor tag) with file name. if click the icon i want to open the selected file in a new window.

How to take the selected file path from the fileupload control.

Geeth
  • 5,282
  • 21
  • 82
  • 133
  • Please clarify. Do you want the path to the file on the client machine? Or the file path to the uploaded file on the server? Or the URL to the uploaded file on the server? – Jeremy Stein May 29 '12 at 12:39

3 Answers3

3

Nathiya,

Do you want to open the file BEFORE it is uploaded to the server?

If the file was already uploaded to the server, then you know the file's path since you passed it to the FileUpload1.SaveAs() method.

If you want it before (e.g. someone clicked on the browse button and choose a file but did not upload it to the server) - Then this is not possible as the file is still on the user's local computer (you can't show files that are on the user's computer, only files that are on your server).

Blachshma
  • 17,097
  • 4
  • 58
  • 72
  • Yes i want to show it before uploading it to the server. that is my problem now... – Geeth May 29 '12 at 12:50
  • 1
    @Nathiya - As I said in my answer, that is not possible.... I think all the answers here give a correct answer to the title of the question (get the selected path) so please accept one. But it seems to me that you should explain exactly what you're trying to achieve because the FileUpload control might not be the correct approach. – Blachshma May 29 '12 at 14:21
2

What i came to know from the search is it is not possible

As it leads to privacy breach and security breach

Please check this Get Full File path

Community
  • 1
  • 1
Vinod
  • 4,672
  • 4
  • 19
  • 26
2

FileUpload1.FileName will give you the name of a file on a client.

EDIT : As per the comment. You should first upload the file to your server. Then use the path (the url to the file) to set as the href value of an achor tag.

Shyju
  • 214,206
  • 104
  • 411
  • 497