【问题标题】:Unable to show images on my web page fetching from FTP server in PHP无法在我的网页上显示从 PHP 中的 FTP 服务器获取的图像
【发布时间】:2018-08-14 03:33:05
【问题描述】:

我无法在我的页面上查看图像,我正在尝试从 FTP 获取图像,但我无法查看图像。我已经创建了本地 FTP 并从本地服务器获取图像并制作图像库,并在上传文件夹中使用多个复选框传输图像后,但这次我无法在网页上查看我的图像,我是 php 的新手。

    <?php
    $qt_folder_name = 'images'; // change this to a folder of your choice for images
            $qt_handle = opendir( dirname( realpath( __FILE__ ) ) . '/' . $qt_folder_name . '/' );

/* ========================================================================== */
/* ========================================================================== */
/*                                    FTP LOGIC                                   */


/* ========================================================================== */

            $qt_counter = 0;



            while( $qt_file = readdir( $qt_handle ) ) :

                if( $qt_file !== '.' && $qt_file !== '..' ) :

                    $qt_counter++;

                    $qt_file_path = $qt_folder_name . '/' . $qt_file;

                    ?>
<!-- ======================================================================= -->                    
          <?php
           $exp=  explode('!',$qt_file);
           ?>
<!-- ======================================================================= -->

                    <div class="qt-photo-gallery-item qt-image-no-<?php echo $qt_counter; ?>">
                        <a class="qt-photo-gallery-item-link" href="<?php echo $qt_file_path; ?>"title="<?php echo $exp[0]."\n".$exp[1]; ?><?php //echo $qt_file;?>">

                            <div class="qt-photo-gallery-item-image-wrapper">

                                <img src="<?php echo $qt_file_path; ?>" class="qt-photo-gallery-item-image" />
                                <p class="title_name"><?php echo $exp[0]."\n".$exp[1]; ?></p>
                            </div>


                        </a>
                    </div>

<!-- ======================================================================= -->

                    <?php

                    if( $qt_counter == 5 ) {
                        $qt_counter = 0;
                    }

                endif;

            endwhile;

/* ========================================================================== */

            ?>

【问题讨论】:

  • 一些合理的代码缩进是个好主意。它可以帮助我们阅读代码,更重要的是,它将帮助 您调试代码 Take a quick look at a coding standard 为您自己谋福利。您可能会被要求在几周/几个月内修改此代码,最后您会感谢我的。

标签: php jquery wordpress image-uploading


【解决方案1】:

乍一看,在 img src= 中,您从文件系统而不是网站的索引目录中引用图像的路径,这可能会导致问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多