蛋糕PHP 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。有什么帮助吗?
最佳答案
我刚刚遇到了完全相同的问题。感谢其他一些评论为我指明了正确的方向,这是我的解决方案:
编辑 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 版本上默认启用该扩展。
关于Cakephp 图像 - 无法确定 mimetype,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20770144/