不允许加载本地资源 - Glob图像

时间:2016-01-04 16:45:32

标签: php image directory glob

修改

它的工作原理如下:

<?php
$dirname = "c://wamp/www/www.mysite.com/uploads/images/cat1/"; 
foreach(glob($dirname.'*') as $filename){
        echo '<img src="../uploads/images/cat1/'.basename($filename).'"/>'; 
}
?>

我在文件夹cat1(本地主机)中有3个图像,我尝试:

foreach(glob('c://wamp/www/www.mysite.com/uploads/images/cat1/*.jpg') as $image){ echo "<img src='".$image."'/>";}

在控制台中返回:

 (index):1 Not allowed to load local resource: file:///c://wamp/www/www.mysite.com/uploads/images/cat1/065.jpg
(index):1 Not allowed to load local resource: file:///c://wamp/www/www.mysite.com/uploads/images/cat1/asus.jpg
(index):1 Not allowed to load local resource: file:///c://wamp/www/www.mysite.com/uploads/images/cat1/asus2.jpg

如何解决错误:不允许加载本地资源?

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

它的工作原理如下:

                            <?php
$dirname = "c://wamp/www/www.mysite.com/uploads/images/cat1/"; 
foreach(glob($dirname.'*') as $filename){
        echo '<img src="../uploads/images/cat1/'.basename($filename).'"/>'; 
}
?>