Take the 2-minute tour ×

I'm setting up the Media Plugin with my Cake 2.1 app. I've used the plugin with Cake 2.0 before and haven't had any problems. Now I'm getting this error message when I try to upload a file:

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

Here's the relevant part of my bootstrap.php file: 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')

...And my model, File.php:

public $actsAs = array(

public $validate = array(
    'file' => array(
        'mimeType' => array(
            'rule' => array('checkMimeType', false, array('image/jpeg', 'image/png', 'image/gif'))

I get the error message above when I submit a form that uploads a file. The line in question in CouplerBehavior.php is:

str_replace('\\', '/', Folder::slashTerm($File->Folder->pwd()))
share|improve this question
add comment

1 Answer

OK, I've done a silly.

I've named my model File. That's obviously the name of the File class in CakePHP. When the file is uploaded, the media plugin is turning it into a new File object, as in a Model. I've renamed my model Attachment instead. Why does this happen - you spend ages thinking about a problem and then as soon as you post a question on the internet you find the answer...

share|improve this answer
At least you didn't name your model Object... –  Adam Marshall Oct 12 '13 at 3:17
add comment

Your Answer


