我正在使用我的 Cake 2.1 应用程序设置媒体插件。我之前用过 Cake 2.0 的插件,没有遇到任何问题。现在,当我尝试上传文件时收到此错误消息:
Fatal error: Call to a member function pwd() on a non-object in /home/fractalw/public_html/cms/app/Plugin/Media/Model/Behavior/CouplerBehavior.php on line 141
这是我的 bootstrap.php 文件的相关部分: CakePlugin::load('Media');
require APP . 'Plugin' . DS . 'Media' . DS . 'Config' . DS . 'core.php';
$thumbnail = array('fitCrop' => array(100, 100));
$small = array('fitCrop' => array(200, 200));
$large = array('fit' => array(700, 10000));
$smallthumbnail = array('fitCrop' => array(75, 75));
$tinythumbnail = array('fitCrop' => array(35, 35));
Configure::write('Media.filter', array('default' => array(
'audio' => array(),
'document' => array(),
'generic' => array(),
'image' => compact('small', 'thumbnail', 'smallthumbnail', 'large', 'tinythumbnail'),
'video' => compact('medium', 'large')
)));
...还有我的模型 File.php:
public $actsAs = array(
'Media.Transfer',
'Media.Coupler',
'Media.Generator',
'Media.GeneratedDeletable',
'Media.Meta',
'Containable'
);
public $validate = array(
'file' => array(
'mimeType' => array(
'rule' => array('checkMimeType', false, array('image/jpeg', 'image/png', 'image/gif'))
)
)
);
当我提交上传文件的表单时,我收到上述错误消息。CouplerBehavior.php 中有问题的行是:
str_replace('\\', '/', Folder::slashTerm($File->Folder->pwd()))