问题
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