473,545 Members | 2,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP-generated link to local file doesn't work when clicked on. Why?

I'm running an Apache server on my own computer (Windows XP Pro).

I wrote a simple PHP script (called test3.php) that I'm running by
putting the following URL in the address bar of the browser (Firefox)
....

http://localhost/test3.php

The script generates the following link using the echo statement ...

<a href="file:///C:/pictures/xyz.jpg"> Picture </a>

("C:/pictures/xyz.jpg", as you can guess by now, is an image file on
my harddrive, but it's not in the document root).

When I clicked on the link, nothing happened. However, if I
RIGHT-click on it and select "Copy link location" (which copies the
URL to the clipboard) and then paste the URL into the address bar of
the browser, the picture then displays correctly.

Why did it not work when I clicked on the link the first time, but it
only worked when I pasted the link to the address bar?

Is there some special notation/syntax that I need to use to get this
to work properly?

May 26 '06 #1
23 5330
wylbur37:
<a href="file:///C:/pictures/xyz.jpg"> Picture </a>


I think - could be wrong - that Firefox doesn't follow file links,
however they're specified, in resources requested by HTTP. It sits and
does nothing. Dunno what other browsers do.

--
Jock

May 26 '06 #2
John Dunlop wrote:
wylbur37:
<a href="file:///C:/pictures/xyz.jpg"> Picture </a>


I think - could be wrong - that Firefox doesn't follow file links,
however they're specified, in resources requested by HTTP. It sits and
does nothing. Dunno what other browsers do.


I have several webpages of HTML code, many of them containing links
to local files on my harddrive (just like the one show above),
and they work just fine when the webpage is opened explicitly
from the browser (and not passed through a local server).

May 26 '06 #3
John Dunlop said the following on 26/05/2006 16:02:
wylbur37:
<a href="file:///C:/pictures/xyz.jpg"> Picture </a>


I think - could be wrong - that Firefox doesn't follow file links,
however they're specified, in resources requested by HTTP. It sits and
does nothing. Dunno what other browsers do.


I'm not sure this makes any sense at all. By definition, a "file://"
link is not an "http://" link, and so doesn't involve HTTP.

As for why it doesn't work for the OP, though, I have no idea.

--
Oli
May 26 '06 #4

"John Dunlop" <us*********@jo hn.dunlop.name> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. .
| wylbur37:
|
| > <a href="file:///C:/pictures/xyz.jpg"> Picture </a>
|
| I think - could be wrong - that Firefox doesn't follow file links,
| however they're specified, in resources requested by HTTP. It sits and
| does nothing. Dunno what other browsers do.

not sure about that. i'd try taking out the additional / after file before
thinking that were the case...

<a href="file://c:/picures/xyz.jpg">file system picture here if clicked</a>
May 26 '06 #5

"Oli Filth" <ca***@olifilth .co.uk> wrote in message
news:k2******** ********@newsfe 4-gui.ntli.net...
| John Dunlop said the following on 26/05/2006 16:02:
| > wylbur37:
| >
| >> <a href="file:///C:/pictures/xyz.jpg"> Picture </a>
| >
| > I think - could be wrong - that Firefox doesn't follow file links,
| > however they're specified, in resources requested by HTTP. It sits and
| > does nothing. Dunno what other browsers do.
|
| I'm not sure this makes any sense at all. By definition, a "file://"
| link is not an "http://" link, and so doesn't involve HTTP.
|
| As for why it doesn't work for the OP, though, I have no idea.

actually oli, iirc the rfc for href is for a URI and not specifically a
URL...where the resource could be even something as non-url as a javascript
function. but i've been wrong before and my memory is not the best.

i think this doesn't work because of the additional / after file://
May 26 '06 #6
robert said the following on 26/05/2006 16:36:
"Oli Filth" <ca***@olifilth .co.uk> wrote in message
news:k2******** ********@newsfe 4-gui.ntli.net...
| John Dunlop said the following on 26/05/2006 16:02:
| > wylbur37:
| >
| >> <a href="file:///C:/pictures/xyz.jpg"> Picture </a>
| >
| > I think - could be wrong - that Firefox doesn't follow file links,
| > however they're specified, in resources requested by HTTP. It sits and
| > does nothing. Dunno what other browsers do.
|
| I'm not sure this makes any sense at all. By definition, a "file://"
| link is not an "http://" link, and so doesn't involve HTTP.
|
| As for why it doesn't work for the OP, though, I have no idea.

actually oli, iirc the rfc for href is for a URI and not specifically a
URL...where the resource could be even something as non-url as a javascript
function.


Indeed, I'm aware of that ;) . However, I now realise that I've misread
John's post, so ignore what I said!
--
Oli
May 26 '06 #7

"Oli Filth" <ca***@olifilth .co.uk> wrote in message
news:In******** *****@newsfe3-win.ntli.net...
| robert said the following on 26/05/2006 16:36:
| > "Oli Filth" <ca***@olifilth .co.uk> wrote in message
| > news:k2******** ********@newsfe 4-gui.ntli.net...
| > | John Dunlop said the following on 26/05/2006 16:02:
| > | > wylbur37:
| > | >
| > | >> <a href="file:///C:/pictures/xyz.jpg"> Picture </a>
| > | >
| > | > I think - could be wrong - that Firefox doesn't follow file links,
| > | > however they're specified, in resources requested by HTTP. It sits
and
| > | > does nothing. Dunno what other browsers do.
| > |
| > | I'm not sure this makes any sense at all. By definition, a "file://"
| > | link is not an "http://" link, and so doesn't involve HTTP.
| > |
| > | As for why it doesn't work for the OP, though, I have no idea.
| >
| > actually oli, iirc the rfc for href is for a URI and not specifically a
| > URL...where the resource could be even something as non-url as a
javascript
| > function.
|
| Indeed, I'm aware of that ;) . However, I now realise that I've misread
| John's post, so ignore what I said!

there's a wink in there, oli...i know you know your stuff many times over.
that was my gentle supposition more for the op and john dunlop.

cheers.
May 26 '06 #8
wylbur37 wrote:
I have several webpages of HTML code, many of them containing links
to local files on my harddrive (just like the one show above),
and they work just fine when the webpage is opened explicitly
from the browser (and not passed through a local server).


Well... wouldn't this lead you to think about the web server blocking
the access to those files? I bet C:\pictures is not part of the normal
web space for your server. Try a simple page such as:

<html>
<head></head>
<body>
<img src="C:/pictures/xyz.jpg">
</body>
</html>

What do your web server logs tell you?

-david-

May 26 '06 #9
wylbur37 wrote:
I'm running an Apache server on my own computer (Windows XP Pro).

I wrote a simple PHP script (called test3.php) that I'm running by
putting the following URL in the address bar of the browser (Firefox)

http://localhost/test3.php

The script generates the following link using the echo statement ...

<a href="file:///C:/pictures/xyz.jpg"> Picture </a>

("C:/pictures/xyz.jpg", as you can guess by now, is an image file on
my harddrive, but it's not in the document root).

When I clicked on the link, nothing happened. However, if I
RIGHT-click on it and select "Copy link location" (which copies the
URL to the clipboard) and then paste the URL into the address bar of
the browser, the picture then displays correctly.

Why did it not work when I clicked on the link the first time, but it
only worked when I pasted the link to the address bar?

Is there some special notation/syntax that I need to use to get this
to work properly?


I just tried running the same script while in Internet Explorer
and it works.

But when I run it in Mozilla 1.4 (suite) or Firefox 1.5,
I get the problem described above.

Usually it's the other way around (i.e., it doesn't work in Internet
Explorer
but works in Mozilla or Firefox).

It must be because of some setting in the browser.
I wonder what it could be.

May 26 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1386
by: Franck | last post by:
Hello, I am currently looking for someone available with good skills in PHP & Postgres in order to develop a little web application that could be done in few days or less. I will pay for that service Feel free to email me at franck75p@yahoo.com if you are interested in this offer. Franck
6
1818
by: Casey Chambliss | last post by:
I'm wanting to develop my own enterprise intranet web portal. I'm very new to PHP and I don't know it well yet, but does anyone have any suggestions on any docs or books that would be a good guide? I already know where the general PHP documentation is and the same goes for mysql. Any documentation or books with lots and lots of examples...
6
4148
by: Jeffrey Silverman | last post by:
Hi, all. Sorry, first off, for the kidna weird selection of crossposted groups, but this question touches on aspects of discussion in each of the groups. So I have a group of around 500 email addresses to which I would like to send a mass email occasionally. The group will never be much larger than 500 email addresses and will occasionally...
2
1799
by: wicky | last post by:
hello, i tried to apply php tags to show some smilies but it wouldn work because my html tag have css class to control it. No picture show up but when i delete the css class the pictures show up, anyon know the reason to this? thank yo <p class="emoticon" <?php foreach($image as $count => $image_path $buf = sprintf("%s",$image_path)
3
1679
by: Tyrone Slothrop | last post by:
The first question, is this even possible? What I need to do is pass the contents of a PHP web page from a textarea using window.open method to a new browser window and display it. The page has a combination of HTML and PHP. The problem is that the PHP is not being interpreted. This is generally resolved by using the PHP eval() function....
0
1483
by: Ben Xia | last post by:
Looks like this is a common issue: If you installed linux Fedora 3 with the default configuration and latest patches, you will have Apache/2.0.53 (Fedora) and PHP 4.3.11 in your box. Without any change you can use sendmail, that means you can use mail under Terminal, but probably you can not use mail() in php. The error message in...
3
2137
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when Record (i) is shown and modified, the change will come to Record (i+1). Can anyone provide suggestion? thanks.
2
1961
by: zeina | last post by:
hi im writing a php scrib and i'm new to this i want to delete informatiom from sql when the user click the check box.how can i do this. here is the code of the tabel: <?php $db = mysql_connect("localhost", "contacts","gotocme"); mysql_select_db("intranet",$db); $result = mysql_query("SELECT CMEer, rfrom, till FROM reservation where...
9
1766
by: art | last post by:
Hi, We have some scripts here where we use some AJAX to populate some of the page. Basically the AJAX routine calls a PHP script. That PHP script uses a bunch of ECHO statements to create the page. Then, we use the innerHTML to populate the section on the page. The problem is, we have a small javascript routine in the middile of
2
2977
by: raamay | last post by:
hello experts, i have fetched records from mysql database and against each record i want to place a update tag which when clicked will update the corresponding record using ajax and php. But here please note that i dont want to use button because its going to look clumpsy if button is placed. Now, once the record is updated it should not show up...
0
7411
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5987
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4962
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3468
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.