[html] How can I create a link to a local file on a locally-run web page?

I'd like to have an html file that organizes certain files scattered throughout my hard drive. For example, I have two files that I would link to:

  • C:\Programs\sort.mw
  • C:\Videos\lecture.mp4

The problem is that I'd like the links to function as a shortcut to the file. I've tried the following:

<a href="C:\Programs\sort.mw">Link 1</a>
<a href="C:\Videos\lecture.mp4">Link 2</a>

... but the first link does nothing and the second link opens the file in Chrome, not VLC.

My questions are:

  1. Is there a way to adjust my HTML to treat the links as shortcuts to the files?

  2. If there isn't a way to adjust the HTML, are there any other ways to neatly link to files scattered throughout the hard drive?

My computer runs Windows 7 and my web browser is Chrome.

This question is related to html anchor local-files

The answer is


If you are running IIS on your PC you can add the directory that you are trying to reach as a Virtual Directory. To do this you right-click on your Site in ISS and press "Add Virtual Directory". Name the virtual folder. Point the virtual folder to your folder location on your local PC. You also have to supply credentials that has privileges to access the specific folder eg. HOSTNAME\username and password. After that you can access the file in the virtual folder as any other file on your site.

http://sitename.com/virtual_folder_name/filename.fileextension

By the way, this also works with Chrome that otherwise does not accept the file-protocol file://

Hope this helps someone :)


I've a way and work like this:

<'a href="FOLDER_PATH" target="_explorer.exe">Link Text<'/a>

back to 2017:

use URL.createObjectURL( file ) to create local link to file system that user select;

don't forgot to free memory by using URL.revokeObjectURL()


Janky at best

<a href="file://///server/folders/x/x/filename.ext">right click </a></td>

and then right click, select "copy location" option, and then paste into url.


Examples related to html

Embed ruby within URL : Middleman Blog Please help me convert this script to a simple image slider Generating a list of pages (not posts) without the index file Why there is this "clear" class before footer? Is it possible to change the content HTML5 alert messages? Getting all files in directory with ajax DevTools failed to load SourceMap: Could not load content for chrome-extension How to set width of mat-table column in angular? How to open a link in new tab using angular? ERROR Error: Uncaught (in promise), Cannot match any routes. URL Segment

Examples related to anchor

How to open a link in new tab using angular? Attaching click to anchor tag in angular How to create a link to another PHP page Making href (anchor tag) request POST instead of GET? Difference between _self, _top, and _parent in the anchor tag target attribute How can I create a link to a local file on a locally-run web page? How to open link in new tab on html? Getting a link to go to a specific section on another page Pure CSS scroll animation Make anchor link go some pixels above where it's linked to

Examples related to local-files

How to fetch data from local JSON file on react native? How can I create a link to a local file on a locally-run web page? Loading local JSON file Check if a file exists locally using JavaScript only Allow Google Chrome to use XMLHttpRequest to load a URL from a local file