View Full Version : HTML Link to Folder on Hard Drive
Vandel212
May 14th, 2010, 02:36 PM
Hi, I'm trying create a link that will open up a folder on my hard drive. I figured you just put the link like this:
<a href="C:\Program Files">Blah</a>
My reasoning was that if I typed in "C:\Program Files" (without quotes) in a browser it would open up the folder. But unfortunatley that does not work.
How would I do this?
Thanks.
msxw
May 14th, 2010, 06:58 PM
mmm you don't use
<a href="C:\Program Files">Blah</a> you use
<a href=file:///blablabla/folder>Open folder</a> instead ;).
mrE
May 15th, 2010, 12:48 AM
if you plan on putting the code up on a server or any other computer, it will look on that user's computer for the files you are calling. make sure if you plan on doing this, to use relative pathing instead of absolute paths like described by msxw.
in other words..... you point to the file from the current working folder. Let's say this is your folder structure somewhere in "My Documents":
website_files
images (folder)
html (folder)
images (folder, inside html folder)
index.htm (inside html folder)
let's say in index.htm you want to open a file or link to a file inside of html/images. you would then say "images/yourfile.extension" instead of "file:///C:/Program Files/etc/etc" - or if you need to go up one folder, it would be "../images/your_other_file.extension"
Visit http://www.communitymx.com/content/article.cfm?cid=230ad for more information.
Vandel212
May 17th, 2010, 11:35 AM
if you plan on putting the code up on a server or any other computer, it will look on that user's computer for the files you are calling. make sure if you plan on doing this, to use relative pathing instead of absolute paths like described by msxw.
I understand wha you are saying. In this situation I doa atcually want it to go on the persons hard drive.
mmm you don't use
<a href="C:\Program Files">Blah</a> you use
<a href=file:///blablabla/folder>Open folder</a> instead ;).
Unfortunatly that did not work. When I click on the link it does nothing. I don't know if you left it out acciendtally, but is it supposed to have quotes around the file path?
mrE
May 17th, 2010, 01:42 PM
I understand wha you are saying. In this situation I doa atcually want it to go on the persons hard drive.
cool. as long as you understand. just trying to give you a heads up in case you did not.
Unfortunatly that did not work. When I click on the link it does nothing. I don't know if you left it out acciendtally, but is it supposed to have quotes around the file path?
Yeah, you need to put quotes around that path - especially if there are spaces in your path. General rule of thumb though - always keep quotes around your values on attributes. It's the XHTML way.
Vandel212
May 17th, 2010, 02:29 PM
Yeah, you need to put quotes around that path - especially if there are spaces in your path. General rule of thumb though - always keep quotes around your values on attributes. It's the XHTML way.
Ok well that still did not work. When I click on the link nothing seems to happen. Another thing that is not working very well is if I use this to link it:
<a href="folder/file.xls">file</a>
It will pop up with the dialog box that allows me the user to either "Open", "Save", or "Cancel". When I click "save" it saves to wherever I choose just fine, but when I click open it freezes on me. I have excel and I know the file is not corrupt, and since it saves correctly it must have read access. So I'm not sure what's up with that...
Thanks
mrE
May 17th, 2010, 02:34 PM
Ok well that still did not work. When I click on the link nothing seems to happen. Another thing that is not working very well is if I use this to link it:
<a href="folder/file.xls">file</a>
It will pop up with the dialog box that allows me the user to either "Open", "Save", or "Cancel". When I click "save" it saves to wherever I choose just fine, but when I click open it freezes on me. I have excel and I know the file is not corrupt, and since it saves correctly it must have read access. So I'm not sure what's up with that...
Thanks
sounds like maybe you need to have excel open before you click on it. but obviously that's not the ideal situation. but try it. see if that works. if it does- it's something janky with your machine. because if it is able to open after saving, it should work when clicking open, too.
Vandel212
May 17th, 2010, 03:28 PM
sounds like maybe you need to have excel open before you click on it. but obviously that's not the ideal situation. but try it. see if that works. if it does- it's something janky with your machine. because if it is able to open after saving, it should work when clicking open, too.
Nope still freezes when I open up excel beforehand. Interestingly enough... if I put it in zip file and I click "Open" it opens up (the zip file, not the excel file) without freezing. So I'm assuming it has something to do with excel.
Clay Dreslough
January 9th, 2012, 04:06 PM
I'm using the code described above and clicking on it does absolutely nothing. I'm using Chrome.
crayzee
January 10th, 2012, 04:46 PM
From what I have read, this is no longer possible. Because of the security concerns with doing such a thing it has been made impossible as long as you are using the http protocol. Most browsers only allow http to access exactly what it was designed to access, and therefore not local computer files.
The only way to do what you're after would be to have the files reside on a local webserver and access them through http://localhost/
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.