By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,841 Members | 840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,841 IT Pros & Developers. It's quick & easy.

Clickable File Link in PHP

P: n/a
I have spent the day learning how to use Zend Development Environment. I
can now produce a list of files in a directory, filtered by extension, and
apparently clickable. Unfortunately clicking on them in a browser doesn't
take me to the file link.

I have found examples for clickable URL's, FTP links and mailto addresses
but not files. I am managing to produce output like this:

<a href="file:///E:/wwwroot/Test/NewListing.php">NewListing.php</a>
<br>
<a href="file:///E:/wwwroot/Test/Public DNS.htm">Public DNS.htm</a>
<br>
<a href="file:///E:/wwwroot/Test/TestList.php">TestList.php</a>
<br>
<a href="file:///E:/wwwroot/Test/Usenet.htm">Usenet.htm</a>

They look fine in a browser (running on Localhost) but I get nowhere
clicking them. If I copy the output from Zend and paste it into an editor
then save it as an html file the links all work fine so the output seems
to be in the correct format.

The examples I found all work so I am coming to the conclusion that either
clickable file links are not possible or I am missing something obvious.

Can anybody give me a steer on this? I want clickable file links rather
than just navigating to a folder so I can control what files are shown
(i.e. just file.html not file.html and the file files directory).

Many thanks.

--
Jeff Gaines Damerham Hampshire UK
There is no reason anyone would want a computer in their home.
(Ken Olson, president Digital Equipment, 1977)
Oct 9 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
In our last episode, <xn****************@news.individual.net>, the lovely
and talented Jeff Gaines broadcast on comp.lang.php:
I have spent the day learning how to use Zend Development Environment. I
can now produce a list of files in a directory, filtered by extension, and
apparently clickable. Unfortunately clicking on them in a browser doesn't
take me to the file link.
I have found examples for clickable URL's, FTP links and mailto addresses
but not files. I am managing to produce output like this:
><a href="file:///E:/wwwroot/Test/NewListing.php">NewListing.php</a>
<br>
<a href="file:///E:/wwwroot/Test/Public DNS.htm">Public DNS.htm</a>
<br>
<a href="file:///E:/wwwroot/Test/TestList.php">TestList.php</a>
<br>
<a href="file:///E:/wwwroot/Test/Usenet.htm">Usenet.htm</a>
They look fine in a browser (running on Localhost) but I get nowhere
clicking them. If I copy the output from Zend and paste it into an editor
then save it as an html file the links all work fine so the output seems
to be in the correct format.
The examples I found all work so I am coming to the conclusion that either
clickable file links are not possible or I am missing something obvious.
Can anybody give me a steer on this? I want clickable file links rather
than just navigating to a folder so I can control what files are shown
(i.e. just file.html not file.html and the file files directory).
I sugget you try to navigate to the files with your browser alone. Bookmark
one of them and then see if your corresponding link looks exactly like the
bookmark.

Although I haven't the foggiest idea how permissions in Windows work (if at
all), if your browser cannot navigate to a file, it's almost a sure bet that
it cannot follow a link to the same file.

It seems barely possible that a Windows browser (i.e. IE) has a weird
interpretation of file urls, such as, maybe, requiring backslashes in file
path part.

It may be that files with spaces require url encoding (ie. <space= %20 ).
That obviously is not your problem now because you are failing on files
without spaces in their names.

Anyway, when you see what your browser thinks a bookmark to the file should
look like, you know what a link it can follow should look like.

--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 468 days to go.
What do you do when you're debranded?
Oct 9 '07 #2

P: n/a
On 09/10/2007 in message
<sl********************@debranded.larseighner.comL ars Eighner wrote:
>In our last episode, <xn****************@news.individual.net>, the lovely
and talented Jeff Gaines broadcast on comp.lang.php:
How did you know that about me, Lars - we've not met :-)
>I sugget you try to navigate to the files with your browser alone.
Bookmark
one of them and then see if your corresponding link looks exactly like the
bookmark.
IE7 just shows the file path in the address bar:
D:\Temp\Listing.html

Firefox shows:
file:///D:/Temp/Listing.html

IE7 uses DOS notation, Firefox Linux notation. Neither will navigate to my
links though :-(
>It may be that files with spaces require url encoding (ie. <space= %20 ).
That obviously is not your problem now because you are failing on files
without spaces in their names.
I've avoided files with spaces so far, that's the next hurdle.
>Anyway, when you see what your browser thinks a bookmark to the file should
look like, you know what a link it can follow should look like.
The link matches what nVU produces if I create the file manually. I just
wondered if it is not working because it is within a php file rather than
an html file. Mind you www type URL's work. Really weird, I'll have to
keep trying I think.

--
Jeff Gaines Damerham Hampshire UK
"Why is it that when we talk to God we're said to be praying,
but when God talks to us we're schizophrenic?"
Oct 9 '07 #3

P: n/a
In our last episode,
<xn****************@news.individual.net>,
the lovely and talented Jeff Gaines
broadcast on comp.lang.php:
On 09/10/2007 in message
<sl********************@debranded.larseighner.com Lars Eighner wrote:
>>In our last episode, <xn****************@news.individual.net>, the lovely
and talented Jeff Gaines broadcast on comp.lang.php:
How did you know that about me, Lars - we've not met :-)
>>I sugget you try to navigate to the files with your browser alone.
Bookmark
one of them and then see if your corresponding link looks exactly like the
bookmark.
IE7 just shows the file path in the address bar:
D:\Temp\Listing.html
Firefox shows:
file:///D:/Temp/Listing.html
IE7 uses DOS notation, Firefox Linux notation. Neither will navigate to my
links though :-(
>>It may be that files with spaces require url encoding (ie. <space= %20 ).
That obviously is not your problem now because you are failing on files
without spaces in their names.
I've avoided files with spaces so far, that's the next hurdle.
>>Anyway, when you see what your browser thinks a bookmark to the file should
look like, you know what a link it can follow should look like.
The link matches what nVU produces if I create the file manually. I just
wondered if it is not working because it is within a php file rather than
an html file. Mind you www type URL's work. Really weird, I'll have to
keep trying I think.
Well, I'm mystified. However if the browser displays the stuff like html,
(hides the tags, underlines the link), I'm pretty sure that it is a .php
file is not your problem.

--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 468 days to go.
What do you do when you're debranded?
Oct 9 '07 #4

P: n/a
On 09/10/2007 in message
<sl********************@debranded.larseighner.comL ars Eighner wrote:
>Well, I'm mystified. However if the browser displays the stuff like html,
(hides the tags, underlines the link), I'm pretty sure that it is a .php
file is not your problem.
I have a solution :-)

You made me think of it so thanks for jogging my brain.

A link in the form:
http://localhost/Test/Usenet.htm

works fine - because I am reading the files on a 'server' not in the file
system.
It doesn't explain why the file link doesn't work but this is probably a
better way of doing it.
It even sorts the spaces out automagically!

--
Jeff Gaines Damerham Hampshire UK
It may be that your sole purpose in life is to serve as a warning to others.
Oct 9 '07 #5

P: n/a
In our last episode, <xn****************@news.individual.net>, the lovely
and talented Jeff Gaines broadcast on comp.lang.php:
On 09/10/2007 in message
<sl********************@debranded.larseighner.com Lars Eighner wrote:
>>Well, I'm mystified. However if the browser displays the stuff like html,
(hides the tags, underlines the link), I'm pretty sure that it is a .php
file is not your problem.
I have a solution :-)
You made me think of it so thanks for jogging my brain.
A link in the form:
http://localhost/Test/Usenet.htm
works fine - because I am reading the files on a 'server' not in the file
system. It doesn't explain why the file link doesn't work but this is
probably a better way of doing it. It even sorts the spaces out
automagically!
Well, yes. Given your development environment this makes perfect sense. Of
course, "file:" should work. but if you do not have to crack this nut, there
is no reason not to leave it as one of those odd things to look into at your
leisure. Sometime things put aside --- because you can put them aside ---
solve themselves because you find the solution to some parallel problem or
notice some clause in a manual that you had overlooked.

I do most of my work from the command line, so if it doesn't work without a
server, I tend to think it doesn't work at all. (The upside is that if it
works on the command line, it will work on the server --- at least that is
my experience so far.) I never see anything working on the server that does
not work on the command line because if it didn't work on the command line I
did not put it on the server.

--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 468 days to go.
What do you do when you're debranded?
Oct 9 '07 #6

P: n/a
Jeff Gaines wrote:
On 09/10/2007 in message
<sl********************@debranded.larseighner.comL ars Eighner wrote:

>In our last episode, <xn****************@news.individual.net>, the lovely
and talented Jeff Gaines broadcast on comp.lang.php:

How did you know that about me, Lars - we've not met :-)

>I sugget you try to navigate to the files with your browser alone.
Bookmark
one of them and then see if your corresponding link looks exactly like the
bookmark.

IE7 just shows the file path in the address bar:
D:\Temp\Listing.html

Firefox shows:
file:///D:/Temp/Listing.html

IE7 uses DOS notation, Firefox Linux notation. Neither will navigate to my
links though :-(

>It may be that files with spaces require url encoding (ie. <space= %20 ).
That obviously is not your problem now because you are failing on files
without spaces in their names.

I've avoided files with spaces so far, that's the next hurdle.

>Anyway, when you see what your browser thinks a bookmark to the file should
look like, you know what a link it can follow should look like.

The link matches what nVU produces if I create the file manually. I just
wondered if it is not working because it is within a php file rather than
an html file. Mind you www type URL's work. Really weird, I'll have to
keep trying I think.

I see you've found a better solution (using localhost), but this is a
Firefox thing:
http://kb.mozillazine.org/Links_to_local_pages_don't_work

I took Firefox developers word for it (security risk),and ended up
putting an alias in apache's httpd_conf file:

Alias /cdrive/ "c:/"

That allows me to use /cdrive/path to file

--
*****************************
Chuck Anderson Boulder, CO
http://www.CycleTourist.com
The world is my country,
Science, my religion.
*****************************
Oct 10 '07 #7

P: n/a
On 10/10/2007 in message <Zb******************************@comcast.com>
Chuck Anderson wrote:
>I see you've found a better solution (using localhost), but this is a
Firefox thing:
http://kb.mozillazine.org/Links_to_local_pages_don't_work

I took Firefox developers word for it (security risk),and ended up putting
an alias in apache's httpd_conf file:

Alias cdrive "c:/"

That allows me to use /cdrive/path to file
Many thanks Chuck, I've read it and book marked it :-)

--
Jeff Gaines Damerham Hampshire UK
It may be that your sole purpose in life is to serve as a warning to others.
Oct 10 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.