I am trying to config开发者_运维技巧ure Media Plugin ( https://github.com/davidpersson/media )
in the core.php
require APP . 'plugins/media/config/core.php';
$xsmall = array('fitCrop' => array(75, 50));
$small = array('fitCrop' => array(75, 50));
$medium = array('fitCrop' => array(220, 140));
$large = array('fitCrop' => array(700, 335));
$xlarge = array('fitCrop' => array(700, 335));
Configure::write('Media.filter', array(
'audio' => array(),
'document' => array(),
'generic' => array(),
'image' => compact('small', 'medium', 'large'),
'video' => compact('medium', 'large')
));
from command line i have created the initial Directories
In my User's Model i have added this
class User extends AppModel {
var $name = 'User';
var $actsAs = array('Containable', 'Media.Transfer', 'Media.Generator', 'Media.Coupler');
Upload form
<!-- Display Photo Form -->
<?php echo $this->Form->create('User', array( 'controller' => 'users','action' => 'display_photo', 'type' => 'file')); ?>
<?php echo $this->Form->input('id'); ?>
<?php echo $this->Form->file('display_photo'); ?>
<?php echo $this->Form->end(array('label' => 'Upload', 'id' => 'upload-button', 'name' => 'upload-button', 'div' => false)); ?>
<!-- Form Ends -->
Action display_photo
function display_photo(){
if(!empty($this->data)) {
debug($this->data);
$this->User->save($this->data, array('fields' => array('display_photo')));
}
}
Error
SQL Error: 1054: Unknown column 'Array' in 'field list'
[CORE\cake\libs\model\datasources\dbo_source.php, line 684]
I’m not sure if the media plugin is capable of saving filenames and directory in one field (from ur ex its: display_photo) but I do sure that if you added fields basename
and dirname
(remove display_photo), I think that should work.
Also you need changed your display fields to echo $this->Form->file('file');
精彩评论