2011-11-14 40 views
-2

我需要幫助才能從我的public_html目錄中的目錄圖像顯示我的圖像。它已經上傳了,但是當我運行下面的php腳本時它不會出現。請有誰知道爲什麼?顯示目錄中的圖像

<?php 
include_once("connect.php"); 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 

<body> 
<?php 
//Retrieves data from MySQL 
$data = mysql_query("SELECT * FROM authors") or die(mysql_error()); 
//Puts it into an array 
while($info = mysql_fetch_array($data)) 
{ 
Echo "<img src=http://giveaway.comli.com/public_html/images/".$info['photo']."> <br>"; 
Echo "<b>Name:</b> ".$info['name'] . "<br> "; 
Echo "<b>Title:</b> ".$info['title'] . " <br>"; 
Echo "<b>Phone:</b> ".$info['description'] . " <br>"; 
Echo "<b><a href=".$info['url'] . ">Link</a><br>"; 
Echo "<b>Country:</b> ".$info['country'] . " <hr>"; 
} 
?> 
</body> 
</html> 

回答

1

是您的public_html目錄真的不是您網站的文檔根目錄嗎?也許你的意思是說:

Echo "<img src=http://giveaway.comli.com/images/".$info['photo']."> <br>"; 

哪裏/images是在現場文檔根目錄。在典型的託管情況下,public_html將是網站文檔根目錄,即從網絡引用(而不是文件系統),它是/

+0

你是對的..你可以看看在該文件夾.. HTTP圖片:// giveaway.comli.com/images/ – SERPRO

+0

與此無關:( – Kelvin

+0

@Kelvin then'$ info ['photo']'不是你期望的那樣。查看你的頁面源代碼,我可以直接鏈接到' http:// giveaway.comli.com/images/LS_The%20Beginning.jpg',所以你需要在'/ images'後面提供正確的文件名 –

0

什麼是您的網站的文檔根目錄?我猜這是/home/.../public_html,這意味着訪問圖像的URL確實是http://giveaway.comli.com/images。您使用的絕對網址只有在您的網站使用多個不同的主機/服務器時才需要,並且/或者打算讓html具有可移植性。你可能只能使用<img src="/images/...">

+0

不適用於那 – Kelvin

0

,我可以看到你的文檔袋鼠目錄public_html,所以URL路徑到你的照片就會像這樣$image_url = "/images/" . $info['photo'];

+0

這使得AW洞新錯誤 – Kelvin