Cakephp image -Can not determine the mimetype
Asked Answered
J

1

5

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?

Joggle answered 25/12, 2013 at 7:18 Comment(6)
PHP Version? Do you have your form set to type file?Polymyxin
Thks Tigran. Yes I have code <?php echo $this->Form->create('Image', array('type' => 'file')); ?> .....echo $this->Form->input('file_name', array('type' => 'file')); ...PHP version 5.3Joggle
Do you have debug set to 2? Is there more than Internal Error message?Polymyxin
Yes I do have it set to 2. I have one Internal Error (the one I posted) and all the other is stack Trace...Joggle
Do you have fileinfo extension on your server? If not, it uses mime_content_type which is deprecated, so it might not be so clever...Confidante
@PapoucheGuinslyzinho did you ever get this to work and also did the unique work since I can't get it to work.Pershing
D
12

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.

Dhoti answered 27/1, 2014 at 23:30 Comment(1)
I think you need to restart xampp after the changes and then the problem is fixedImplausibility

© 2022 - 2024 — McMap. All rights reserved.