2011-11-14 4 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 디렉토리는 실제로 사이트의 문서 루트가 아닙니까? 아마 당신은 말을 의미 : /images 사이트의 문서 루트 디렉토리입니다

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

합니다. 일반적인 호스팅 상황에서는 public_html이 사이트 문서 루트가됩니다. 즉 파일 시스템이 아닌 웹에서 참조하는 사이트 문서 루트는 /입니다.

+0

당신이 맞아요 .. 해당 폴더 .. HTTP의 사진을 볼 수 있습니다 : // giveaway.comli.com/images/ – SERPRO

+0

이것으로도 작업하지 않습니다 : ( – Kelvin

+0

@Kelvin'$ 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

관련 문제