473,856 Members | 1,415 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 5402
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
1401
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
1832
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 would be great. I've considered using phpWebSite and phpNuke, but I don't really want to spend...
6
4179
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 be about half that size. I have written a simple HTML interface and PHP backend to process the...
2
1810
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
1698
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. However, since the page contents are being passed via JS, the eval is evaluting the JS statement...
0
1508
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 maillog will looks like: "SYSERR(APACHE), Can't write, ... Permission denied."
3
2156
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
1976
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 rdate = '$resdate' AND type = 'conference' ",$db);
9
1786
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
2992
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 in the page. How can i do it? Initially, each record will have a status as 0 but once i update...
0
9922
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9766
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11066
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10702
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10391
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9536
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7935
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7099
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5963
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.