Ga3tan
Ga3tan

Reputation: 95

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.

Upvotes: 1

Views: 3197

Answers (4)

Vaas
Vaas

Reputation: 67

Distribute your app as ElectronJS application. This will allow you to get seamless access to your local file system and web features.

Upvotes: 3

Ga3tan
Ga3tan

Reputation: 95

I found a solution for Firefox, with a plugin here

But you also need to download something to install on Windows or Linux following the plugin installation.

I'm still looking for the same solution for IE.

Upvotes: 0

Okoch
Okoch

Reputation: 465

It sounds like you have to configure your Apache to map a resource on your filesystem:

Have a look here and probably use the Alias directive.

httpd.conf

Alias "/resources/" "C:/users/myusername/public/resources/"

And then use it as below:

<a href="/resources/mydoc.docx">Link to local file</a>

Upvotes: -2

Quentin
Quentin

Reputation: 943217

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.

Upvotes: 0

Related Questions