0
votes

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(
    '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'))
        )
    )
);

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()))
1

1 Answers

1
votes

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...