如何使用cakephp显示或打印目录中的所有图像
我是cakephp新手,非常感谢您的帮助如何使用cakephp显示或打印目录中的所有图像,php,cakephp,cakephp-3.0,Php,Cakephp,Cakephp 3.0,我是cakephp新手,非常感谢您的帮助 <?php $dir = new Folder(WWW_ROOT . '/img/profile/'.$profile); $files = $dir->find('.*', true); pr($files);exit; ?> 我不知道如何通过循环打印图像 我可以在目录中回显1个图像 echo $this->Html->image('profile/' .$br.$
<?php
$dir = new Folder(WWW_ROOT . '/img/profile/'.$profile);
$files = $dir->find('.*', true);
pr($files);exit;
?>
我不知道如何通过循环打印图像
我可以在目录中回显1个图像
echo $this->Html->image('profile/' .$br.$profile.$br.stream_get_contents($users->profile_pic),array('width'=>'250px','height'=>'250px'));
profile_pic是数据库中的图像字段如果要显示实际图像,可以制作如下内容:
foreach($files as $file){
echo "<img src='./img/profile/$profile/$file'>";
}
stream_get_contents()期望参数1是资源,字符串给定[APP/Template\Users\profile.ctp,第54行]echo$this->Html->image('profile/'。$br.$profile.$br.stream_get_contents($file))$users->profile\u pic是图像的名称或类型?是每次我更改profile\u pic时图像的字段名称\u pic图像位于当前用户的目录中。我已更新我的答案。流\u get\u内容不是必需的
foreach($files as $file){
echo "<img src='./img/profile/$profile/$file'>";
}
foreach($files as $file){
echo $file . "<br>"; // The br is optional
}
echo $this->Html->image('profile/' .$br.$profile.$br.$file);