cakePHP读取文件夹目录并仅显示某些文件类型
在列出文件夹中的所有文件时,我不希望显示任何.db文件 这是我的密码:cakePHP读取文件夹目录并仅显示某些文件类型,php,file,cakephp,directory,Php,File,Cakephp,Directory,在列出文件夹中的所有文件时,我不希望显示任何.db文件 这是我的密码: $ticketId = 100; $uploadPath = Configure::read('Config.uploadPath').'/support_tickets/'; $dir = new Folder($uploadPath.$ticketId); $fileList = $dir->read(true, array('*.db')); 现在$fileList存储所有文件 如何正确编写语句?我将尝试$fi
$ticketId = 100;
$uploadPath = Configure::read('Config.uploadPath').'/support_tickets/';
$dir = new Folder($uploadPath.$ticketId);
$fileList = $dir->read(true, array('*.db'));
现在$fileList存储所有文件
如何正确编写语句?我将尝试$files=$dir->find('.*.db',false) 对于这种类型的东西来说是很棒的。这里是SVG文件的基本示例
/**
* @brief SvgIterator for finding svg files
*/
class SvgIterator extends FilterIterator {
public function accept() {
$isSvg = $this->current()->getExtension() == 'svg';
if(!$isSvg) {
return false;
}
return $this->_getData();
}
/**
* @brief method for getting data from the SVG files
*
* @return boolean
*/
protected function _getData() {
$this->current()->_aspectRatio = SvgConvert::aspectRatio($this->current()->getPathname());
return true;
}
/**
* @brief calculate the aspect ratio of the curret file
*
* @return float
*/
public function aspectRatio() {
return $this->current()->_aspectRatio;
}
}
使用方法:
$it = new SvgIterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($path)));
$return = array();
for ($it->rewind(); $it->valid(); $it->next()) {
$file = array(
'file' => $it->current()->getFilename(),
'aspect_ratio' => $it->aspectRatio()
);
$return[] = $file;
}