[英]How i can get size OR ext from files in cakephp
In controller: 在控制器中:
public function Attachments(){
$this->layout = null;
$folder = new Folder(WWW_ROOT.'/files/attachments');
$files = $folder->find('.*\.*');
$this->set('files', $files);}
In View (Attachments.ctp): 在视图中(Attachments.ctp):
<?php foreach($files as $file): ?>
<i><?php echo $file; ?></i>
<?php endforeach; ?>
How i can get size OR ext !? 我如何获得尺寸或分值!
Below is action in my PostController 以下是我的PostController中的操作
public function attachments(){
$dir = new Folder(WWW_ROOT.'files/attachments');
$files = $dir->read(true);
foreach ($files['1'] as $k=>$v)
{
$fileObj = new File(WWW_ROOT.'files/attachments/'.$v);
$info[]=$fileObj->info();
}
$this->set('info',$info);
}
and below is code of attachments.ctp file 以下是附件.ctp文件的代码
<?php
foreach ($info as $k=>$v)
{
echo $v['extension'].'<br/>';
echo $v['filesize'].'<br/>';
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.