How to serve local files via browser

823 views Asked by At

I'm making an intranet page where the users will put in some information (text). My application will take this text and go through files on a shared drive that the webserver has access to. Based on the text and some logic it'll find the file that matches.

Now that I have the full absolute file path of the matched file, I'd like the users to be able to download the file from the page as well. However, since the file doesn't exist in my application I can't serve it.

All I have is the network share like: \\somenetwork\share\filename.pdf

Is there a way I can let users download this file (with the above path) from the intranet page?

I've tried:

<a href="\\somenetwork\share\filename.pdf"> but that does not work. also tried prepending file:// but that link does nothing. not even open the file or give the option to download.

PS: I understand that this should ideally be a script on the command line. I'm just trying to turn a command line script into an intranet page.

1

There are 1 answers

0
Nick Grealy On

This works in chrome and ie. For a txt file on a shared drive (that I have access to), it opens the file in the browser.

<a href="file://\\server\d$\Temp\clipboard.txt">test</a>

You have to ensure the user has access to the shared drive for this to work. Otherwise you'll need to host the file somewhere (e.g. via the webserver).