带有空格的PHP rawurlencode路径失败,无法找到文件

时间:2017-04-20 18:13:36

标签: php urlencode

我有一个像这样的文件路径:

/example/img/letter_images/Chapter 2 The Heller Family

包含名为Letter #1等的子文件夹。当我尝试使用以下方式在该文件夹中显示图像时:

<?php
class struct
{
    public static function imageDisplayGallery($img_folder_path)
    {

        $index=0;
        foreach(glob("$img_folder_path*/*_thumb.jpg") as $thumb)
        {
            $full=str_replace("_thumb","",$thumb);
            //echo "$full-$thumb";

            echo '<a href="',rawurlencode($full),'" class="photo-link smoothbox" rel="gallery"><img src="',rawurlencode($thumb),'" /></a>';
            $index=$index+1;

            if($index % 6 == 0)
            {
                echo '<div class="clear"></div>';
                $index=0;
            }
        }
    }
}

$images=struct::imageDisplayGallery('img/letter_images/Chapter 2          The Heller Family/');
?>

我在控制台中收到错误消息:

http://www.example.com/img%2Fletter_images%2FChapter%202%20%20%20%…%20%20%20%20The%20Heller%20Family%2FLetter%20%23%209%2Fpfr100350_thumb.jpg

未找到。有人可以解释为什么会这样吗?

当我只使用urlencode时,我得到+而不是空格(这显然是错误的)。我还能尝试解决这个问题吗?

0 个答案:

没有答案
相关问题