Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 19, 2012 01:21 PM by bbcompent1
Apr 19, 2012 12:27 PM|LINK
What I want is to open a local xls file from page that runs locally as well in IE 8.
I expected a dialog with "Do you want to open or save this file?" and MS Excel starting after "Yes" is pressed.
Clicking on this link doesn't do anytnig - no errors, no exceptions, no security warnings.
<a href="file:///C:\Folder\New Microsoft Excel Worksheet.xlsx">Existing</a>
However, if I right-click and choose "Save Target As" dialog appears file is found and can be saved, also. if right-click and choose "Copy Shortcut" and paste it to IE it will prompt to open file.
Same reference in <asp:HyperLink> doesn't work either.
http:\\localhost is already at trusted IE sites.
Apr 19, 2012 12:30 PM|LINK
Make your link like this:
%20 is the unix equivalent of space. Hypertext protocol is essentially unix based :)
Apr 19, 2012 12:36 PM|LINK
Yieks, seems like I've posted the link that I've got after 4h of experiments.
OK. Same behaviour if link looks like the following:
Apr 19, 2012 12:37 PM|LINK
You have an extra / in front of the c: drive. Should only be two not three.
Certain files do behave differently in IE. Excel, Word, etc. are what is known as "Active Documents". That means IE knows how to view them and is able to load Word and Excel interfaces into the IE container in order to view the file. IE is not going to ask
you to download a file in this case since it knows how to view the file. Browsers generally will only ask you to open or save a file if they do not know, or are designed not to view a file. To IE though, a word or excel doc is the same as a web page. It's
just a link that it knows how to view.
Just to make sure, you do understand that this type of link will only work on your computer and not anyone else viewing the page since the file doesn't exist on their computers. I'm only mentioning this because many people mistakenly use file protocol for
a link thinking it's for downloading files.
Apr 19, 2012 12:40 PM|LINK
He's correct. If its intranet, you can do something like
file://server/share/folderpath/file.xlsx and that will work. However, when you go to put it on the internet, it won't work because outside PCs are not part of your domain. In that way, you have to follow internet web conventions for file downloads like
Apr 19, 2012 12:49 PM|LINK
I've tried the
This gives me a link that's resolved as "file:///C:/TMP/New%2520Microsoft%2520Excel%2520Worksheet.xlsx" in IE ( I guess that it was encoded twice as %20 was replaced with %2520) and doesn't work at all (neither on click, nor on Save As)
I've also tried the
<a href="file://C:/TMP/New Microsoft Excel Worksheet.xlsx">Existing</a>
That still doesn't work on click.
I suppose /// stands for the root directory on your machine in "file:///"
Apr 19, 2012 12:50 PM|LINK
As I've mentioned it is ASP that runs locally, and accesses local file.
Apr 19, 2012 12:52 PM|LINK
Ok, try your link this way:
<a href=@"C:\tmp\yourexcel file.xlsx>Click me</a>
Apr 19, 2012 12:56 PM|LINK
<a href=@"C:\TMP\New Microsoft Excel Worksheet.xlsx">Click me</a>
is displayed as "http://localhost/WebApplication2/@%22C:/TMP/New" at IE and surely fails.
Apr 19, 2012 01:02 PM|LINK
Take a look at this thread:
Although i still think it is a programming question, it was answered here: http://superuser.com/questions/103026/open-a-direct-file-on-the-hard-drive-from-firefox-file Both Firefox and IE8 support the File URI scheme.
Here are some examples valid for Windows systems, referring to the same file c:\WINDOWS\clock.avi
file://localhost/c|/WINDOWS/clock.avi file:///c|/WINDOWS/clock.avi file://localhost/c:/WINDOWS/clock.avi file:///c:/WINDOWS/clock.avi While the last is the most obvious and human-readable, the first one is the most complete and correct one.
Apparently (from the same url):
Mozilla browsers refuse to follow file URLs on a page that it has fetched with the HTTP protocol but:
Mozilla browsers can be configured to override this security restriction as detailed in Mozillazine's "Links to Local Pages Don't Work".