Search code examples
javascriptphphtmlfilelocal

Access to local files only work with local HTML file


I would like to access a local file on my computer by clicking on a HTML link

<a href="file:///\\mynetworklink\users\myusername\public\mydoc.docx">Link to local file</a>

It works very well if I do it from a local HTML file for exemple from :

file:///D:/Profiles/myusername/Desktop/testfile.html

It even work well by using window.open from Javascript :

    <script type="text/javascript">
    window.open('\\\\mynetworklink\\users\\myusername\\public\\mydoc.docx', 'MyWindow');
    </script>

But when I do it from my local PHP app with Apache if am not allowed to do so. Exemple of error while trying with a link tag :

Not allowed to load local resource

So I heard that Chrome/Firefox/IE are blocking local file access this way for security reasons.

Isn't there any way to make it work without modifying the browsers settings ? This app is used by a lot of customers and I can't ask everybody to modify there settings.

Thank you, Best regards.


Solution

  • So I heard that Chrome/Firefox/IE are blocking local file access this way for security reasons.

    Yes

    Isn't there any way to make it work without modifying the browsers settings ?

    No. That would make it a pointless security feature.