簡體   English   中英

圖像將無法使用PHP從圖像文件夾正確上傳

[英]images will not upload properly from images folder with php

我編寫了一個函數,可以使用PHP將圖像文件從文件夾上傳到網頁。 HTML正確輸出,但是圖像不顯示。 當我檢查Web控制台時,我看到“ i”代替圖像源。 我確定這里發生了什么,因為我確實看到了正確數量的斷開鏈接,而不是圖像

    <?php
    // grabs work.php imgs from imgs folder

    $files = GLOB('imgs/*.*');

    //PRINT_R($files);

    function generateImgs($items) {
    $html = "<div class=\"container\">
                <ul class=\"row\">\n";
    foreach ($items as $item){
        $html .= "<li class=\"col-lg-2 col-md-2 col-sm-3 col-xs-4\"><img src=\"imgs/$item[0]\"/></li>\n";
    }
    $html .= "</ul> </div>\n";
    return $html;
    }

    echo generateImgs($files);

    ?>

經過一番混亂和變化

     <img src=\"imgs/$item[0]\"/>

     <img src=\"./$item'[0]'\"/>

現在,我在Web控制台中看到要顯示到img的整個路徑,但是在文件名之后有%27%5B0%5D%27字符是%27%5B0%5D%27 該字符串位於圖像文件的每個GET請求的末尾。

請改用以下代碼:

foreach ($items as $item){
    $html .= "<li class=\"col-lg-2 col-md-2 col-sm-3 col-xs-4\"><img src=\"imgs/$item\"/></li>\n";
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM