简体   繁体   English

php图片包含问题

[英]php image include problem

im using this php file as a header in my site. 即时通讯使用此php文件作为我的网站中的标题。 my problem is that i have included an image but it is does not displayed what is the problem?? 我的问题是我已经包含了一个图像,但它没有显示出什么问题? this is my code 这是我的代码

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<h2><center><img src="../../../../Users/sermed/Desktop/Manar's New web site/Harbourheader.gif" /></center></h2>
<center><b><font color="#000000">You logged in as : <? echo "<font color=#000000>$user1</font>";?></b></center>
<hr width=500>
<center><a href="main.php" class=links><font color="#000000">Home</font></a> | <a href="yachts.php" class=links><font color="#000000">Yachts</font></a> | <a href="buy.php" class=links><font color="#000000">Buy</font></a> | <a href="ret.php" class=links><font color="#000000">View History</font></a> | <a href="report.php" class=links><font color="#000000">Report</font></a> | <a href="help.php" class=links><font color="#000000">Help</font></a> | <a href="logout.php" class=links><font color="#000000">Logout</font></a><center>
<hr width=750>

</body>
</html>

img src必须引用可以下载映像的URL,而不是它本地磁盘上的路径。

You can't just access any file on the hard drive you want. 您不能只访问所需硬盘上的任何文件。 If it is above the directory that is at the base of you WebServer (eg. localhost/ or mysite.com/) you cannot use .. to get higher into the file system. 如果它位于WebServer基础上的目录(例如localhost /或mysite.com/)之上,则无法使用..来获得更高的文件系统。 I am guessing that is what you problem is. 我猜这就是你的问题所在。

It looks to me that you are using the path on your machine as opposed to the server path and that it is outside of your web root. 在我看来,您正在使用计算机上的路径而不是服务器路径,并且它位于Web根目录之外。

Move the image to an images directory within your website and reference it with an absolute path. 将图像移动到网站中的图像目录,并使用绝对路径引用它。

<img src="/images/Harbourheader.gif" />

Generally speaking, an img tag does not "include" an image in an HTML file. 一般来说,img标签不会在HTML文件中“包含”图像。 An img tag tells the browser to make another request to a server to get the file. img标记告诉浏览器向服务器发出另一个请求来获取文件。 It's all client-side, not server-side. 它是所有客户端,而不是服务器端。

For that reason, the src must refer to a resource that is accessible to the browser. 因此,src必须引用浏览器可访问的资源。 As others have said, it should be a URL. 正如其他人所说,它应该是一个URL。 In examples where it doesn't look like a URL (eg /images/Harbourheader.gif) it's because the browser will prepend the same server name to get the img that it used to get the original page. 在它看起来不像URL的例子中(例如/images/Harbourheader.gif),这是因为浏览器会预先添加相同的服务器名称以获取用于获取原始页面的img。

-- -
bmb BMB

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM