Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在5列中显示文件夹中的图像_Php_Image_Upload - Fatal编程技术网

Php 在5列中显示文件夹中的图像

Php 在5列中显示文件夹中的图像,php,image,upload,Php,Image,Upload,您好,我正在查看我要删除的文件夹中的文件,现在可以正常工作,但图像在一个列表中,我想在5列中显示图像,我尝试添加一个表,但无法使其工作,有什么想法吗?这是我的密码 <form id="stallionidelete" method="post" enctype="multipart/form-data"> <?php $dir = dirname(__FILENAME__)."/images/gallery" ; $files1 = scandir($dir); foreach

您好,我正在查看我要删除的文件夹中的文件,现在可以正常工作,但图像在一个列表中,我想在5列中显示图像,我尝试添加一个表,但无法使其工作,有什么想法吗?这是我的密码

<form id="stallionidelete" method="post" enctype="multipart/form-data">
<?php
$dir = dirname(__FILENAME__)."/images/gallery" ;
$files1 = scandir($dir);
foreach($files1 as $file) {
    if(strlen($file) >=3) {
        $foil = strstr($file, 'jpg'); // As of PHP 5.3.0
        $foil = $file;
        $pos = strpos($file, 'css');
        if ($foil==true) {
            $i == ++$i;
            echo '<table><tr>';
            echo '<div class="gimage_'.$i.'"><input type="checkbox" id="gimage_'.$i.'" name="filenames['.$i.'][]" value="'.$foil.'" />';
            echo "<img width='150' height='150' src='images/gallery/$file' /><br/></div>";
            echo '</tr></table>';
            // for live host
            //echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/$file' /><br/>";
        }
    }
}
?>
<input type="submit" name="mysubmit2" value="Delete">
</form>

这就是您应该如何编写代码的方法

    <form id="stallionidelete" method="post" enctype="multipart/form-data">
   <table border='1' width='546' cellspacing='0' cellpadding='0' bordercolor="#E1F5FF">
<tr>
            <td>
            <table  summary='table' style="width: 797px">
    <thead id="start">
        <tr>
            <th width='150' style="height: 40px">Image1</th>
            <th width='150' style="height: 40px">image2</th>
             <th width='150' style="height: 40px">Image3</th>
            <th width='150' style="height: 40px">image4</th>
             <th width='150' style="height: 40px">image5</th>

            </tr>
    </thead>
        <tfoot>
    </tfoot>
    <tbody>
<tr>

        <?php
        $dir = dirname(__FILENAME__)."/images/gallery" ;
        $files1 = scandir($dir);
        foreach($files1 as $file){
        if(strlen($file) >=3){
        $foil = strstr($file, 'jpg'); // As of PHP 5.3.0
        $foil = $file;
        $pos = strpos($file, 'css');
        if ($foil==true){
        $i == ++$i;
        echo '<td bgcolor="#F7F7F7" width="183">';
        echo '<div class="gimage_'.$i.'"><input type="checkbox" id="gimage_'.$i.'" name="filenames['.$i.'][]" value="'.$foil.'" />';
        echo "<img width='150' height='150' src='images/gallery/$file' /><br/></div>";
        echo '</td>';
         // for live host
        //echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/$file' /><br/>";
        }
        }
        }?>
        </table>
    </tr>  
        </tbody>
    </table></td>
            </tr>
        </table>
        </form>
        <input type="submit" name="mysubmit2" value="Delete">

图1
图2
图3
图4
图5
您不必回显表格,也可以忘记放置
标签


我想消除误解,你能检查一下,告诉我这是否是你需要的吗?

我想下面的内容会有所帮助

$dir = dirname(__FILENAME__)."/images/gallery" ;
$files1 = scandir($dir);

if ($files1) {

    echo '<table>';
    $fileCount = 0;
    foreach($files1 as $file){

        if(strlen($file) >=3 && strstr($file, 'jpg')){

            if ($fileCount % 4 == 0) {
               if ($fileCount > 0) {
                   echo '</tr>';
               }
               echo '<tr>';
            }

            echo '<td>
                     <input type="checkbox" id="gimage_'.$i.'" name="filenames['.$i.'][]" value="'.$foil.'" />
                     <img width="150" height="150" src="images/gallery/'.$file.'" />
                  </td>';

            $fileCount++;
        }
    }
    if ($fileCount > 0){
        if ($fileCount % 4 > 0){
            echo '<td colspan="'.($fileCount%4).'"></td>';
        }
        echo '</tr>';      
    }
    echo '</table>';

    echo '<input type="submit" name="mysubmit2" value="Delete">';
}
$dir=dirname(_文件名)“/images/gallery”;
$files1=scandir($dir);
如果($1){
回声';
$fileCount=0;
foreach($files1作为$file){
如果(strlen($file)>=3&&strstr($file,'jpg')){
如果($fileCount%4==0){
如果($fileCount>0){
回声';
}
回声';
}
回声'
';
$fileCount++;
}
}
如果($fileCount>0){
如果($fileCount%4>0){
回声';
}
回声';
}
回声';
回声';
}

感谢您的回复,我已经尝试过了,但仍在一列中:-(你想把它们放在垂直栏中吗?比如12345
678910
等等,我查了一下你的网站,它们是分开的
我想你的意思是如何把它们放在垂直栏中,对吗?抱歉,是的,一行5个,然后转到下一行。想分享哪一行吗?回音“”;谢谢,它到了,没有图像,虽然在表格图像中。我我把它留给你微调;)唯一的问题是,当我试图删除图像时,它会留在那里:(