Website has tag, where href is path to local file.
For example, <a href="D:\test.txt">Link</a>
.
It doesn't work.
How to do it right? :) It must work in IE only, other browsers are not necessary
While in the browser, press Ctrl+O in Windows (Cmd+O on Mac) as in “Open” and double-click the appropriate file.
Opening a Local File on Chrome is quite simple, you just have to open a New Tab, hit Ctrl+O, go to your file's location, select and open it. There are different types of files one can open in Chrome Browser such as Text, video files, . mp3 files, images, etc.
To make certain file types OPEN on your computer, instead of Chrome Downloading... You have to download the file type once, then right after that download, look at the status bar at the bottom of the browser. Click the arrow next to that file and choose "always open files of this type". DONE.
Here you need to use a "file" protocol to link a file in the HTML like,
<a href="file:///D:\test.txt">Link</a>
The browser may or may not open the file due to the security setting. You can click the right button and choose "copy link address" and then paste it into the browser.
I came across the same problem and looked for a solution but couldn't find anything, file:// was saying not allowed to open local file and this wouldn't be possible to work
May not solve it for everybody but I did a workaround in php using file_get_contents(). It's a function in php that gets the text content of a file and puts it into a variable - which does allow you to access local files on a network.
So you just make a php file that takes the id or string of the file and pulls the data and use php to put it onto the screen so as far as the browser is concerned its a hosted file
<a href='getContents.php?id=5'>
getContents.php
<?php
$id = $_GET['id'];
if(ctype_alnum($id)){//
//get file name from Database
$data[5]['file_path'] = 'file.htm';
$page = file_get_contents('//server//'.$data[$id]['file_path']);
echo $page;
}
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With