0

我正在尝试显示在线目录中的图像,但图像未正确显示并且破坏了我可以做些什么来正确显示这些所有图像

 <?php 
 // Connects to your Database 
 include_once("connection.php");
 //read image directory     
$images_dir = '/home/qeplaho/public_html/image/';
function ListFiles($images_dir) {
    if($dh = opendir($images_dir)) {
        $files = Array();
        $inner_files = Array();
        while($file = readdir($dh)) {
            if($file != "." && $file != ".." && $file[0] != '.') {
                if(is_dir($images_dir . "/" . $file)) {
                    $inner_files = ListFiles($images_dir . "/" . $file);
                    if(is_array($inner_files)) $files = array_merge($files, $inner_files); 
                } else {
                    array_push($files, $images_dir . "/" . $file);
                }
            }
        }
        closedir($dh);`enter code here`
        return $files;
    }
}
echo "<table>";
foreach (ListFiles('/home/qeplaho/www/image/') as $key=>$file){
    echo "<tr>";
    echo"<td>";
    echo '<img src=\"$images_dir\" width="200" height="200"/>';
    echo "</td>";
    echo "</tr>";
}
 echo "</table>";`<code>
4

1 回答 1

0

这应该可以解决问题:

$handle = opendir(dirname(realpath(__FILE__)).'/pictures/');
        while($file = readdir($handle)){
            if($file !== '.' && $file !== '..'){
                echo '<img src="pictures/'.$file.'" border="0" />';
于 2013-07-05T11:24:52.587 回答