Clickable File Link in PHP
Clickable File Link in PHP
am 09.10.2007 18:38:56 von Jeff Gaines
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:
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)
Re: Clickable File Link in PHP
am 09.10.2007 19:09:18 von Lars Eighner
In our last episode, , 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:
>
>
>
>
>
>
>
> 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. = %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
Countdown: 468 days to go.
What do you do when you're debranded?
Re: Clickable File Link in PHP
am 10.10.2007 00:42:07 von Jeff Gaines
On 09/10/2007 in message
Lars Eighner wrote:
>In our last episode, , 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. = %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?"
Re: Clickable File Link in PHP
am 10.10.2007 00:55:54 von Lars Eighner
In our last episode,
,
the lovely and talented Jeff Gaines
broadcast on comp.lang.php:
> On 09/10/2007 in message
> Lars Eighner wrote:
>>In our last episode, , 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. = %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
Countdown: 468 days to go.
What do you do when you're debranded?
Re: Clickable File Link in PHP
am 10.10.2007 01:04:34 von Jeff Gaines
On 09/10/2007 in message
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!
--
Jeff Gaines Damerham Hampshire UK
It may be that your sole purpose in life is to serve as a warning to others.
Re: Clickable File Link in PHP
am 10.10.2007 01:35:36 von Lars Eighner
In our last episode, , the lovely
and talented Jeff Gaines broadcast on comp.lang.php:
> On 09/10/2007 in message
> 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
Countdown: 468 days to go.
What do you do when you're debranded?
Re: Clickable File Link in PHP
am 10.10.2007 06:00:36 von Chuck Anderson
Jeff Gaines wrote:
> On 09/10/2007 in message
> Lars Eighner wrote:
>
>
>> In our last episode, , 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. = %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.
*****************************
Re: Clickable File Link in PHP
am 10.10.2007 10:04:05 von Jeff Gaines
On 10/10/2007 in message
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.