Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hyperlink to file on C: drive does not work

 
Yuma Shankar
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSP page where I am providing a hyperlink to a file on the C: drive as follows

<a href="C:\ReqImport\data.txt" target=_blank >Try this </a>

Nothing happens when I click this hyperlink.

When I scroll over the hyperlink I see the correct path "file:///C:/ReqImport/data.txt" in the status bar and when paste this path in my address bar, it does open up the file.

Any ideas why this file hyperlink does not work on this JSP page.

Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It shouldn't work.
Browsers shouldn't grant access to resources on the client's hard drive.

Why would you want to link to local files from a webapp?
 
Yuma Shankar
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The webapp is processing a data file on the users hard drive and then writing to an error file on the drive. So the hyperlink is for the user to open that error file.


Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The user should have to explicitly upload the file to be processed.
Think of the horrible things that a nefarious site could do if it were allowed to read and write from/to your hard drive.

If you want to bypass browser security, you might want to look into signed applets.
 
Yuma Shankar
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben!
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In theory the link "file:///C:/ReqImport/data.txt" should cause the browser to show the specified file (or prompt for download, depending on the file type).

Since this was a security concern, Internet Explorer 6 with Service Pack 1 now blocks the file protocol from being used by Internet sites. It will still work locally within Windows.

See also:
http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/predefined/file.asp

Similarly, Netscape 7 blocks this by default. It is possible to unlock the file protocol in Netscape if you (personally) want it to work.

See also:
http://www.unc.edu/ais/directories/mozilla_fix.html

Of course, accessing client-local resources should never be a design 'feature' of your site!
[ December 30, 2005: Message edited by: Charles Lyons ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic