Cakephp image -Can not determine the mimetype

放肆的年华 提交于 2020-01-23 07:00:27

问题


cakephp 2.3

I'm uploading an image and I have an error saying that:

Can not determine the mimetype.

Error: An Internal Error Has Occurred.

On my Model this is a part of my $validation

'file_name' => array(
            'uploadError' => array(
                'rule' =>'uploadError',
                'message' => 'Your image upload failed',
                'allowEmpty' => FALSE,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
            'mimeType' => array(
                'rule' => array('mimeType', array('image/gif', 'image/png', 'image/jpg', 'image/jpeg')),
                'message' => 'Please only upload images (gif, png, jpg).',
                'allowEmpty' => FALSE,
                ),
            'fileSize' => array(
                'rule' => array('fileSize', '<=', '2MB'),
                'message' => 'Your image must be less than 2MB or(2048ko).',
                'allowEmpty' => FALSE,
                ),
            'processCoverUpload' => array(
                'rule' => 'processCoverUpload',
                'message' => 'Unable to process cover image upload.',
                'allowEmpty' => FALSE,
                ),
            'unique' => array(
                'rule' => 'isUnique',
                'message' => 'This file name is already exist in your folder',
                'required' => 'create',
                'allowEmpty' => FALSE,
                ),
        ),

I'm only allow 3 types of mimetype. any help?


回答1:


I just ran into exactly the same problem. Thanx to some other comments which pointed me in the right direction, here is my solution: Edit php.ini (\xampp\php\php.ini on Win7) search for extension=php_fileinfo.dll and uncomment it.

FYI: I'm running xampp 1.7.7 [Apache:2.2.21; PHP:5.3.8; MySQL:5.5.16]. Hopefully on newer xampp versions the extension is enabled by default.



来源:https://stackoverflow.com/questions/20770144/cakephp-image-can-not-determine-the-mimetype

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!