cakephp 2.3
我正在上传图片,但我说错误:
Can not determine the mimetype.
Error: An Internal Error Has Occurred.
在我的模型上,这是我的$ 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。有什么帮助吗?
答案 0 :(得分:12)
我遇到了完全相同的问题。 Thanx对其他一些评论指出了我正确的方向,这是我的解决方案:
编辑php.ini(Win7上的\ xampp \ php \ php.ini)搜索extension=php_fileinfo.dll
并取消注释。
仅供参考:我正在运行xampp 1.7.7 [Apache:2.2.21; PHP:5.3.8; MySQL的:5.5.16。希望在较新的xampp版本上,默认情况下会启用扩展名。