0
votes
'model' => array(
        'rule' => array('isValidExtension', array('xls')),
        'message' => 'File does not have a stl extension'
        ),

Allows absolutely any file to be uploaded. I have this is as my first validation rule. Other validation rules like notEmpty, and isUnique work fine on the same form element.

Tried adding stl to the array found in the main behavior: 'extensions' => array('xls') - also did not work.

Any idea on what I'm doing wrong here?

Also: This appears to happen regardless of the file extension I pick. No matter what, it doesn't call the file invalid. The same issue appears to happen with Mime types as well.

The plugin URL is: https://github.com/josegonzalez/upload EDIT: Upon further investigation of UploadBehavior.php, and some debugging it doesn't seem like any of the custom validaiton rules are being loaded. I wonder why this could be?

2

2 Answers

0
votes

Have you tried going through the plugin code while your upload is in progress? The validation function is located in

Model/Behavior/UploadBehavior.php line 746

I suggest you put a couple of pr() and die() statements to see what the value of the $check and $extensions variables are.

Don't forget to remove those after!

0
votes

Diagnosed the problem and fixed:

I had bad syntax in my model validations.

I had several of the same in a row like:

'model'=> array(
       'rule' => 'rule',
       'message' => 'message'
 ),
 'model'=> array(
       'rule' => 'rule',
       'message' => 'message'
 ),
 'model'=> array(
       'rule' => 'rule',
       'message' => 'message'
 )

Seems this was the cause of the problem. Substituting

'model' => array(
   'rulename' => array(
                'rule' => array('rule'),
                'message' => 'message'
                ),

    'rulename' => array(
                'rule' => array('rule'),
                'message' => 'message'
                ),

    'rulename' => array(
                'rule' => array('rule'),
                'message' => 'message'
                )
    )