473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Clickable File Link in 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).

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
7 2598
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
by: Kerberos | last post by:
I followed Dan Cederholm's image replacement tutorial, to replace a header tag by a logo. The h1 is clickable if no CSS is applied but it I replace it by the logo, the area isn't clickable anymore...
5
by: Matt Bostock | last post by:
Hi, Please see: http://www.drfunkenstein.net/catalogue/categories/fancydress/81/go/2/ ...and try clicking on the '< previous' link underneath the costume thumbnails. The link is only...
3
by: Yeah | last post by:
Through CSS, is there a way to change the color of a table cell on a hover? By the way, the cell also contains a link - the text link and table cell mouseover should both be clickable to the link's...
3
by: mallyonline | last post by:
Thank you for your previous help. I posted regarding listing the names of files held in a folder on the server and making the list appear clickable. This has now been accomplished. The...
2
by: John A. | last post by:
Hello. I'm trying to have an image (a GIF with transparency) overlayed on certain of several inline images that link to different pages. What I have so far looks right (or right enough) in...
2
by: Krustov | last post by:
The question of how to create thumbnails with clickable links gets asked on this newsgroup every so often - like clock work . Just really posing this script here for google to archive it & so...
3
by: Irocivan | last post by:
Hello, I download a nice collapse menu for free distribution from the internet. It works very well except that none of the parents nodes are clickable (i.e. when clicking on the parent node, the...
2
by: Tina I | last post by:
Hi everyone, A short and sweet question: Is it possible to put a clickable link in a QLabel that will open in the systems default browser? I tried to put in some HTML but it did (of course?)...
2
by: shing | last post by:
As a start page I usually have several of my bookmarks and a "Home portal". I have decided that I want a new feature. <html> <script language="javascript">...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.