cakephp 2.4上传图片

时间:2014-01-08 04:47:33

标签: cakephp cakephp-2.3

我正在尝试使用此Behavior (github) tutorial

上传图片并制作此图片的缩略图

我正在使用cakephp网站上的博客教程。

每次我想上传图片时,我都会收到以下错误。我正在下载.jpeg文件

Invalid file type. Only .jpg, .jpeg, .png, .gif allowed.

我的模特/ Post.php

<?php

class Post extends AppModel {
        public $validate = array(
        'title' => array(
            'rule' => 'notEmpty'
        ),
        'body' => array(
            'rule' => 'notEmpty'
        )
    );

public $actsAs = array('ImageUpload' => array(
        'image' => array(
            'required'               => false,
            'directory'           => 'img/uploads/',
            'allowed_mime'        => array('image/jpeg', 'image/pjpeg', 'image/gif', 'image/png'),
            'allowed_extension'   => array('.jpg', '.jpeg', '.png', '.gif'),
            'allowed_size'        => 2097152,
            'random_filename'     => true,
            'resize' => array(
                'thumb' => array(
                    'directory' => 'img/uploads/thumbs/',
                    'phpThumb' => array(
                        'far' => 1,
                        'bg'  => 'FFFFFF',
                        'zc' => 0
                    ),
                    'width' => 230,
                    'height' => 150
                ),
                'max' => array(
                    'directory' => 'img/uploads/thumbs/',
                    'phpThumb' => array(
                        //'far' => 1,
                        //'bg'  => 'FFFFFF',
                        'zc' => 0
                    ),
                    'width' => 400,
                    'height' => 300
                )
            )
        )
    )
);

}

0 个答案:

没有答案