so, i've ben hunting for the answer, and seems like i can't get this to work, i wanted to make so that, i have a browser page already made in html, and when i click a link in there, it opens a chosen folder on the computer, but i don't want it to open on just this computer's path, I wanted to open a folder that is inside the main folder, so that anyone that has the same files as I do, can open it, i tried < a href="File_path">, tried putting < a href="file:///(file path)">, tried like i have in excel ../../'file path', and can't see where is the problem, anyone can help?
2 Answers
Here you need to use a "file" protocol to link a file in the HTML like,
<a href="file:///D:\test.txt">Link</a>
The browser may or may not open the file due to the security setting. You can click the right button and choose "copy link address" and then paste it into the browser.

- 132
- 2
- 12
-
Thanks, that does work, but i wanted it to open the folder, same way as you click the folder on your computer, it opens on the desktop, is there any way to make it happen here? – Caganonick Apr 17 '17 at 10:03
-
Also, i want it to get the folder adress as the start point, instead of D:, how do i do that? – Caganonick Apr 17 '17 at 10:14
-
file:///C:\Users\estagio\Desktop\Certificacao\Atendimento\2011\Processos Prestação de Serviços\Secretaria\Fluxogramas\P-AD-02 Recepção de Pedidos de Reg. de Cid. Comunitários n This is the full path of the folder, and Certificacao being the mail folder where everything is, can i create like a variable that gets the path where the file is, on any computer, and access the folder in any location? that is my question – Caganonick Apr 17 '17 at 10:28
There are security implications of showing a local file/folder from an website. It may work when the page is held locally but when on a server it will be failing. However definitely not any chosen folder anywhere in your PC.
If you require to achieve such you need custom implementation using a programming language like ASP .NET like shown in this example. https://stackoverflow.com/a/6047826/684030
You haven't mention much details on what web server you are using. But if it's IIS (Windows) you may consider allowing directory browsing which may allow to show a sub directory under your website.

- 1
- 1

- 674
- 9
- 23
-
Ok, so forgeting the oppening event of a local folder, as i mention above on the last comment to Shabarish Shetty, how can i get the path to that folder, not only on my computer, but to whoever uses this folder? – Caganonick Apr 17 '17 at 10:44
-
Are you trying to load/ show content from the users local folder or folder from web server where your html is hosted? – Randi Ratnayake Apr 17 '17 at 10:49
-
-
Sorry you can't navigate to users local folder. Period! It's basic HTTP security.The only way you can navigate through users local file system is using file upload control and user deliberately picking a file. Even for that you can't set a default location. – Randi Ratnayake Apr 17 '17 at 10:58
-
Yea but in this example given, Link, it opens on my browser the folder, and the contents on the folder, i wanted something like that, but on my example, but having some kind of variable to set a path to where the folder is located, for example, here when i'm working at, its C:\Users\estagio\Desktop\Certificacao, and for example, the computer that my boss works on is different im sure, so in my example, the variable would capture the C:\Users\estagio\Desktop\Certificacao, and then i'd set manually the path to where the especified file i want to read is located – Caganonick Apr 17 '17 at 11:03
-
Understanding you are using plain html there is no out of the box way to make your path configurable, other than replacing the path directly. And what I see is your html is only going to be used in users local box. Usually when we do server side web development we use either web.config (for ASP.net) PHP.ini (for PHP) to read configurable values. – Randi Ratnayake Apr 17 '17 at 11:24
-
-
Will say you find a way. Wouldn't the end result will be same. Since you got to replace the value for each and every client/ instance? – Randi Ratnayake Apr 17 '17 at 11:55
-
Well there is my problem, i wanted that ''variable'' to work on every client/instance/computer, to get the general path to where the folder is located – Caganonick Apr 18 '17 at 13:02
-
May be see this example. That's the best I could come up with the information you have provided. https://plnkr.co/edit/ePRDVD73eqJQfJJt4v88?p=preview – Randi Ratnayake Apr 18 '17 at 13:28
-
So imagining someone stores it in their file:///D:\\documents, can't i get a single variable to the location? to be dynamic, instead of having to change the path everytime someone gets the file, as u saw already, im not expert at this at all, but i understood the thing u sent me, and its ery very close to what i wanted, but without having to put the path manually – Caganonick Apr 18 '17 at 14:37
-
You still didn't mention where you trying to host this HTML or how you planning to distribute the solution. Is it going to be stored in individual user's PC or in a server? The configurable variable should come from somewhere it's stored. Usually, we put them in a config file or database. In your case, you can't have both since you are using plain old HTML. – Randi Ratnayake Apr 19 '17 at 06:49
-
Its going to be stored in individual user's PC, just a small number of people are going to have access to that folder, so its going to be distributed by hand to each person – Caganonick Apr 19 '17 at 15:43
-
I only know html really, for this type of things, i know c, c#, VB net, but that doesnt matter really for what im trying to archieve, what kind of language do you recomend for this kind of stuff – Caganonick Apr 19 '17 at 15:50
-
You still didn't tell me where you going to host your HTML or what server. Simple things like this would have been achieved with no effort via ASP.Net (C#/ VB) or PHP... they all still more HTML with a bit of server side coding. In simple: HTML is a presentation markup language which your browser understand how to render it. HTML is not designed to do even simple math function. – Randi Ratnayake Apr 20 '17 at 01:32
-
Alright thanks for the answers, aleady took to much of your time, I'm going to search more about how to do this with another language, other than html :) I gotta change my whole code, oh god, got already like 30 pages of html code :/ – Caganonick Apr 20 '17 at 08:12