【发布时间】:2014-01-13 05:49:02
【问题描述】:
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。有什么帮助吗?
【问题讨论】:
-
PHP 版本?您是否将表单设置为输入
file? -
感谢蒂格兰。是的,我有
codeForm->create('Image', array('type' => 'file')); ?> .....echo $this->Form->input('file_name', array('type' => 'file')); ...PHP 5.3 版 -
您是否将调试设置为 2?除了内部错误消息吗?
-
是的,我确实将它设置为 2。我有一个内部错误(我发布的那个),另一个是堆栈跟踪...
-
您的服务器上有
fileinfo扩展吗?如果不是,它使用已弃用的mime_content_type,所以它可能不那么聪明......
标签: cakephp cakephp-2.0 cakephp-2.3