图片上传pulgin josegonzalez / cakephp-upload

时间:2014-04-02 07:50:11

标签: php cakephp

我在cakephp中使用这个“josegonzalez / cakephp-upload”插件来上传图片。当我上传图像时,它保存在db和location中。现在我想要更改图像名称,并且该图像名称保存在db和location中。我怎么能通过这个插件来做到这一点。如果有人知道请帮助我......

这是我的代码

public $actsAs = array(
    'Containable',
    'Upload.Upload' => array( 
        'img' => array(
                'fields' => array(
                    'dir' => 'img_dir'
                ),
                'thumbnailSizes' => array(
                    'big'   => '639x423',
                    'small' => '130x130',
                    'thumb' => '90x82'
                ),
                'thumbnailMethod' => 'php',
                'path'            => '{ROOT}webroot{DS}img{DS}brand{DS}{field}{DS}',
                'deleteOnUpdate'  => true
        )
    )
);

1 个答案:

答案 0 :(得分:2)

您放置了额外的数组换行

public $actsAs = array(
    'Containable',
    'Upload.Upload' => array(
        'path' => '{ROOT}webroot{DS}img{DS}brand{DS}{field}{DS}',        
        'fields' => array(
            'dir' => 'img_dir'
        ),
        'thumbnailSizes' => array(
            'big'   => '639x423',
            'small' => '130x130',
            'thumb' => '90x82'
        ),
        'thumbnailMethod' => 'php',
        'deleteOnUpdate'  => true
        ),
        'thumbnailName' => '{filename}_{size}_{geometry}'
    )
);