Make sure <a href="local file"> is opened outside of browser

19,165

Do you WANT people to just mess around with things lying on your server? That reeks of lack of security to me...

I'd recommend letting the user check it out locally and using a database or similar to allow people to check in new drafts. Said drafts should be verified and validated somehow before they are actually written to the server's filesystem.

Share:
19,165
Can Sahin
Author by

Can Sahin

Updated on June 04, 2022

Comments

  • Can Sahin
    Can Sahin almost 2 years

    For an Intranet web application (document management), I want to show a list of files associated with a certain customer. The resulting HTML is like this:

    <a href="file:///server/share/dir/somefile.docx">somefile.docx</a>
    <a href="file:///server/share/dir/someotherfile.pdf">somefile.pdf</a>
    <a href="file:///server/share/dir/yetanotherfile.txt">yetanotherfile.txt</a>
    

    This works fine. Unfortunetly, when clicking on a text file (or image file), Internet Explorer (and I guess most other browsers as well) insist on showing it in the browser instead of opening the file with the associated application (e.g. Notepad). In our case, this is undesired behavior, since it does not allow the user to edit the file.

    Is there some workaround to this behavior (e.g. something like <a href="file:///..." open="external">)? I'm aware that this is a browser-specific thing, and an IE-only solution would be fine (it's an Intranet application after all).