8

I have an page with some forms. All the links work fine in IE. They open in a new tab nicely when the hyperlink is click by the user; however, I realized that when Chrome is use the link doesn't open. I keep clicking but nothing opens. The only way of opening the file is copying the hyperlink, opening a new tab in Chrome, paste and go.

<a href="FILE:\\outsideserver\files\shared\form1.pdf" target="_blank">Form1</a>

Is this something that browser do? Because I tried it with FireFox and doesn't work either? It there a way of going around? without installing anything in the browser? Because my user loves Chrome. Thank you in advanced for the responses.

sergio089
  • 143
  • 1
  • 1
  • 8
  • See here: http://stackoverflow.com/questions/2087894/can-google-chrome-open-local-links - you can't open file links unless the page is it's self a local file, for security. There is an extension mentioned in the link that might work around your issue. – Dan Smith Feb 25 '15 at 16:50
  • 1
    This worked for me in Chrome: Form1 – access_granted Nov 21 '17 at 21:03

4 Answers4

5

You can't access to files outside your server or "SandBox", sandbox include the files that user push to the browser or to your server.

If the access from browser to a pc files from web pages was possible, it would be a security problem.

ppascualv
  • 1,137
  • 7
  • 21
  • Is it possible to access a pdf / text file that users drag and drop on a browser? Is this case considered as "sandbox" ? – Jun Sep 07 '18 at 17:40
  • Yes, it's possible. If your user is uploading files at your app this is inside your sandbox. – ppascualv Sep 17 '18 at 10:01
  • what if the user is not uploading, the user just uses chrome to open a local pdf file. and, on that tab, there is my chrome extension, do u know if I can access the file using my chrome extension? – Jun Sep 17 '18 at 18:47
  • @Jun711 Yes, you can, in this scenario. – Matthew C Dec 07 '22 at 11:16
2

The answer is that you can't with your approach and more importantly you shouldn't. Chrome behavior is in fact the right behavior and it protects you from having malicious users and/or scripts accessing your local resources.

The FILE protocol will access local or defined network named resources which will not be available to a remote user that visits the same page. In other words, you may have outsideserver mapped as a network resource/drive but someone else will not (This does not apply to IPs)

Here's what you can do:

Community
  • 1
  • 1
dwkd
  • 2,716
  • 1
  • 17
  • 17
2

Use the below extension for chrome. It will work.

Enable local file links

Below both options are working and tested.

<a href="\\server\folder\">Link 2</a>

<a href="file:///C:/folder/test.txt">Link 3</a>
   
Rohit Vyas
  • 790
  • 6
  • 16
  • 2
    thanks. but this is only for clicking!?? am I right? ----------------- do you know anything better? I want some background passive extension that just enable accessing file:/// – Mohammad_Hosein Jan 21 '21 at 11:48
0

I know this is pretty old but the issue remains in 2023 - the inability to view file:/// links in browsers w/out manual/user interaction. My use case may be rare but here is my poor man's workaround if anyone wants to use: https://gist.github.com/cemerson/cb2da58243837b41b4aaa4541a2380f3 (Code is fast and sloppy so feel free to clean up)

Basically it's just a simple HTML page that takes a querystring value of the target file path and it gives the user a way to grab the path URL and/or the file:/// to paste/view themselves in the browser. Having the ability to get a working HTTPS URL that pointed to a local/shared drive file was my primary need/objective and this works for now.

Christopher
  • 1,639
  • 19
  • 22