Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why file:///server/share/filename.pdf acts unexpected

Status
Not open for further replies.

Dirtbike

IS-IT--Management
Dec 9, 2002
81
US
When I create a static page with a reference to file:///server/share/file.pdf the page works as expected. When the page that references that same reference is served up by IIS (or Apache) the link doesn't work. Can you guys enlighten an HTML newbie?

 
Sure the link is valid...it works from the "static" page.. I no not what you speak of relative to file protocols. Can you clarify?
 
I was asking whether the link was using a file protocol (file://) or an http protocol (
Surely you must know this, otherwise how can you code the link? Or, do you just have a relative link with no protocol, leaving it to default to whichever protocol is used to load the page?

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I think I've duplicated the problem, so perhaps I can clarify. Dirtbike, please tell me if I've got this right.

I have a WinXP Pro system with a local IIS server running. My web root is "D:\Inetpub\ I created an HTML file containing the following:
Code:
<html>
<head>
<title>Test</title>
</head>
<body>
<p><a href="file:///d:/Inetpub/[URL unfurl="true"]wwwroot/test.txt">Test[/URL] file</a></p>
</body>
</html>
The referenced test.txt file is just a plain text file with some random keyboard-banging in it.

If I go to D:\Inetpub\ and double-click on test.html to open it in Firefox, clicking on the link shows me the contents of test.txt. If I open it by starting Firefox and entering in the address bar, I see the same test.html page, but if I click on the link, nothing happens. The same is true if I duplicate the procedure with IE6.

I have absolutely no idea why this happens. Perhaps it's a web browser security measure? All I can say is that you probably shouldn't be putting file:// URIs in non-local web pages. Just copy the file somplace under the web root and serve it with an http:// URI. If it changes regularly, set up a nightly cron job or scheduled task to copy the new version into the web root.
 
Thanks guys...I found this to be true...

<p><a href="file:///C:/test.pdf">dude</a></p>
This above code works from a static page but does nothing when hit from a page served by IIS...but the below works...not that they are looking at the same fiel be cause they are not. i guess it is a security issue...or that I must conform to a \\server\sharename\ format.

<p><a href="file://Engine01/D/Inetpub/
 
When the file is loaded locallly (i.e. NOT via a web server), then "C:/..." would be a valid path.

When served via a web server, it is most likely that this is NOT a valid path, so you would have to change it to be relative to your initial document, or to the root of your WEB SERVER, not your DRIVE.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top