【发布时间】:2013-11-22 21:05:22
【问题描述】:
好的,我正在尝试此处指定的文件和文件夹类:
http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#
我的文件夹控制器如下所示:
<?php
App::uses('AppController', 'Controller');
App::uses('Folder', 'Utility');
App::uses('File', 'Utility');
class FolderController extends AppController {
public $uses = array();
public function display() {
$dir = '/var/www/html/letters/pdfdir/';
$files = $dir->find('.*\.pdf', true);
foreach ($files as $file) {
$file = new File($dir->pwd() . DS . $file);
$contents = $file->read();
echo 'CONTENT: '.$contents;
// $file->write('I am overwriting the contents of this file');
// $file->append('I am adding to the bottom of this file.');
// $file->delete(); // I am deleting this file
$file->close(); // Be sure to close the file when you're done
}
}
}
但我收到以下错误:
错误:在非对象上调用成员函数 find() 文件:/var/www/html/letters/app/Controller/FolderController.php 线路:13
任何帮助表示赞赏。
问候
【问题讨论】:
标签: cakephp