Cakephp图像 - 不能确定mimetype [英] Cakephp image -Can not determine the mimetype

查看:108
本文介绍了Cakephp图像 - 不能确定mimetype的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

cakephp 2.3

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.

在我的模型中,这是我的$ validation的一部分

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,
                ),
        ),

我只允许3种类型的mimetype。任何帮助?

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

推荐答案

我刚刚遇到完全相同的问题。 Thanx的一些其他意见,指向我的方向正确,这里是我的解决方案:
编辑php.ini(\xampp \php\php.ini在Win7)搜索扩展= php_fileinfo.dll 并取消注释。

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:我运行xampp 1.7.7 [Apache:2.2.21; PHP:5.3.8; MySQL:5.5.16]。希望在较新的xampp版本上,扩展名默认启用。

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.

这篇关于Cakephp图像 - 不能确定mimetype的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆