When I type URL

file://///server01\PUBLIC\PEG\

in browser address bar, browser redirecting to that location and shows the documents available. But when I use same url in href browser not redirecting to the href location.

<?php
echo '<a href="file://///server01\PUBLIC\PEG\">click here</a>';
echo '<a href="file://///server01/PUBLIC/PEG/">click here</a>';

?>

php code is not working. When I click click here nothing will be happend.Browser not redirecting to corresponding location.
I tested in all browsers. Application running in remote server.

Recommended Answers

All 3 Replies

The file:// protocal only works in localhost and instead you need to use the http:// address to your file. For example: If you were to type into the url bar to download the file www.example.com/peg/ then the code would be as follows.

<a href="http://www.example.com/peg/">click me</a>

Also the url demonstrated will open the directory the file is in rather the download it. To download it you will need something like the following.

<a href="http://www.example.com/peg/download.zip">click me</a>

server01 is the host name.

I cannot user http:// to open document location.If I type this in browser URL

http:////server01/PUBLIC/PEG/

browser shows **The address is not valid **

The follwoing code is working in IE 8 but not in mozilla and chrome.

<?php
echo '<a href="file://///server01\PUBLIC\PEG\">click here</a>';
echo '<a href="file://///server01/PUBLIC/PEG/">click here</a>';
?>

How to make this code works for all browsers?

http:////server01/ is not a valid host name. Editing the hosts.cfg file I belive it's called will not publish your localhost site on the internet. You will need to purchase what is called a "domain name" and in addition to that if you wish to run it off your computer you will need to "port foward". Also after purchasing the domain name you will need to configure the "dns" with a program such as "bind" but in general it is a lot easier to pay monthly for a "web host". Some web hosts are free with certain limitations. So I would strongly recommend purchasing a webhost rather than trying to run it off your own computer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.