views:

28

answers:

1

Hello. I would like to use the [MeioUpload Behavior][1] for uploading documents like PDF, DOC, XLS etc. but I get an Invalid file type error.

My Upload Model looks like this:

class Upload extends AppModel {
 var $name = 'Upload';
 var $actsAs = array(
   'MeioUpload.MeioUpload' => array(
         'upload_file' => array(
             'dir' => 'files{DS}uploads',
             'create_directory' => true,
             'allowed_mime' => array('application/pdf', 'application/msword', 'application/mspowerpoint', 'application/excel', 'application/rtf', 'application/zip'),
             'allowed_ext' => array('.pdf', '.doc', '.ppt', '.xls', '.rtf', '.zip'),
         )
     )
 );
}

When I debug the $defaultOptions $options['allowedMime'] in the MeioUpload class... it's uses the default allowedMime:

Array
(
    [0] => image/jpeg
    [1] => image/pjpeg
    [2] => image/png
    [3] => image/gif
    [4] => image/bmp
    [5] => image/x-icon
    [6] => image/vnd.microsoft.icon
)

Why is the Behavior not using my declared allowed_mime ???

Any idea how I can overwrite the default allowed_mime???

A: 

Ok, sorry... stupid question...

In the Upload Model you need to write the options in camelCase:

   ... 
    'allowedMime' => array('application/pdf', 'application/msword', 'application/mspowerpoint', 'application/excel', 'application/rtf', 'application/zip'),
'allowedExt' => array('.pdf', '.doc', '.ppt', '.xls', '.rtf', '.zip'),
    ...
Juri