单击时,PHP生成的本地文件链接不起作用。为什么? [英] PHP-generated link to local file doesn't work when clicked on. Why?

查看:70
本文介绍了单击时,PHP生成的本地文件链接不起作用。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在自己的计算机上运行Apache服务器(Windows XP专业版)。


我写了一个简单的PHP脚本(称为test3.php),我是运行

将以下URL放在浏览器的地址栏中(Firefox)

....

http://localhost/test3.php


脚本生成以下内容使用echo语句链接...


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


(C:/pictures/xyz.jpg",你现在可以猜到,是一个图像文件

我的硬盘,但它不在文档根目录中。


当我点击链接时,什么也没发生。但是,如果我

右键单击它并选择复制链接位置 (将

URL复制到剪贴板),然后将URL粘贴到浏览器的地址栏中,然后将图片正确显示。


当我第一次点击链接时为什么它不起作用,但是只有当我将链接粘贴到地址栏时才能使用


我需要使用一些特殊的符号/语法来使这个

正常工作吗?

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?

推荐答案

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




我认为 - 可能是错的 - Firefox没有关注文件链接,

但是他们'在HTTP请求的资源中指定。它坐着并且

什么都不做。 Dunno其他浏览器的功能。


-

Jock



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


John Dunlop写道:
John Dunlop wrote:
wylbur37:
wylbur37:
< a href =" file:/// C:/pictures/xyz.jpg">图片< / a>
<a href="file:///C:/pictures/xyz.jpg"> Picture </a>



我认为 - 可能是错的 - Firefox没有关注文件链接,
但它们是在指定的资源中指定的HTTP。它坐着,什么都不做。 Dunno其他浏览器的功能。



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.




我有几个HTML代码网页,其中很多包含链接

到我的硬盘上的本地文件(就像上面的一个节目一样,

,当网页从浏览器中明确打开时,它们工作得很好

来自浏览器(而不是通过本地服务器)。 />



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).


John Dunlop于26/05/2006 16:02发表以下内容:
John Dunlop said the following on 26/05/2006 16:02:
wylbur37:
wylbur37:
< a href =" file:/// C:/pictures/xyz.jpg">图片< / a>
<a href="file:///C:/pictures/xyz.jpg"> Picture </a>



我认为 - 可能是错的 - Firefox没有关注文件链接,
但它们是在指定的资源中指定的HTTP。它坐着,什么都不做。不知道其他浏览器做什么。



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.




我不确定这根本没有意义。根据定义,file://

链接不是http://。链接,所以不涉及HTTP。


至于为什么它不适用于OP,但我不知道。

-

Oli



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


这篇关于单击时,PHP生成的本地文件链接不起作用。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆