2

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.

Anthony
  • 33,838
  • 42
  • 169
  • 278
  • I think you would need you server to serve the files. I see you tagged 'java', is php allowed? I have done similar tasks through php requests. – ılǝ Aug 29 '13 at 00:26
  • Sure, let me know how you would serve it with php. Would I have to read in the file and then serve it out via my server? – Anthony Aug 29 '13 at 00:28
  • Excuse me, small correction. I misunderstood that users will also upload files (for which php is a solution). A regular get request from the client should work since your web server has access to the drive. – ılǝ Aug 29 '13 at 00:38
  • What happens if you just paste the link to the file in a browser address bar? – ılǝ Aug 29 '13 at 00:39
  • @ile if I paste the `file://...` link in the browser address bar then the file shows up fine. – Anthony Aug 29 '13 at 00:46
  • Odd. Do you get any errors in the browser's console when you click on your download link? http://\\address is the correct syntax, the problem should be elsewhere – ılǝ Aug 29 '13 at 00:53
  • apparently having `file://` in `anchor` tag does not trigger a request. – Anthony Aug 29 '13 at 01:20
  • 1
    apparently doesn't work on mac and chrome http://stackoverflow.com/questions/4763863/anchor-link-to-local-file-a-href-file-pathdead-link-a-not-working – Anthony Aug 29 '13 at 01:23

1 Answers1

0

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).

Nick Grealy
  • 24,216
  • 9
  • 104
  • 119