Re: Is it possible to validate a file upload?
The file validation is not implemented yet, i had to write the code (works for me) and uploaded it to trac.cakephp.org, This is the ticket https://trac.cakephp.org/ticket/4170 On Jan 11, 12:41 am, "Louie Miranda" <[EMAIL PROTECTED]> wrote: > I just want to be able to validate a file upload, but validation don't work. > > view > create('Catalog', array('action' => 'update', 'type' => > 'file'));?> > file('File'); ?> > input('Remarks', array('rows'=>'10', 'cols'=>'50'));?> > submit('Update pricelist');?> > end(); ?> > > model > var $validate = array( > 'File' => VALID_NOT_EMPTY, > 'Remarks' => VALID_NOT_EMPTY, > ); > > Validation works on Remarks, but on file. It does not say, field is > required. > > Did, i miss something here? I am using 1.2.x (latest beta) > > -- > Louie Miranda ([EMAIL PROTECTED])http://www.axishift.com > > Security Is A Series Of Well-Defined Steps > chmod -R 0 / ; and smile :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Is it possible to validate a file upload?
Just found out that my hint was wrong... use /** * Checks if given data is valid */ private function isHtmlFormFileData($data) { if(!is_array($data)) { return false; } if(!array_key_exists('name',$data) || !array_key_exists('type',$data) || !array_key_exists('tmp_name',$data) || !array_key_exists('error',$data) || !array_key_exists('size',$data)) { return false; } return true; } On 13 Jan., 18:06, davidpersson <[EMAIL PROTECTED]> wrote: > I implemented such a validation method in one of the classes I'm using > for my project: > > See > Source:https://cakeforge.org/plugins/scmsvn/viewcvs.php/trunk/vendors/transf... > > Scroll down to: > /** > * Checks if given data is valid > */ > private function isHttpPostData($data) > > On 11 Jan., 12:02, Marcin Domanski aka kabturek <[EMAIL PROTECTED]> > wrote: > > > Hey> Did, i miss something here? I am using 1.2.x (latest beta) > > > Yep ;) > > did you see the actual Remarks field after posting data? try > > debug($this->data);die(); if you dont have a debugger. > > Cake is right by telling you its not empty cause it contains an array > > of $_FILE['field'] so it is ALWAYS not empty. > > Use customvalidationto check if ['Remarks']['tmp_name'] is not > > empty, ['error;[ == 0 , and ['size'] != 0 etc > > > HTH, > > Marcin Domanski aka kabturekhttp://tumble.kabturek.info/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Is it possible to validate a file upload?
I implemented such a validation method in one of the classes I'm using for my project: See Source: https://cakeforge.org/plugins/scmsvn/viewcvs.php/trunk/vendors/transfer.php?rev=74&root=attm&view=markup Scroll down to: /** * Checks if given data is valid */ private function isHttpPostData($data) On 11 Jan., 12:02, Marcin Domanski aka kabturek <[EMAIL PROTECTED]> wrote: > Hey> Did, i miss something here? I am using 1.2.x (latest beta) > > Yep ;) > did you see the actual Remarks field after posting data? try > debug($this->data);die(); if you dont have a debugger. > Cake is right by telling you its not empty cause it contains an array > of $_FILE['field'] so it is ALWAYS not empty. > Use customvalidationto check if ['Remarks']['tmp_name'] is not > empty, ['error;[ == 0 , and ['size'] != 0 etc > > HTH, > Marcin Domanski aka kabturekhttp://tumble.kabturek.info/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Is it possible to validate a file upload?
Hey > Did, i miss something here? I am using 1.2.x (latest beta) Yep ;) did you see the actual Remarks field after posting data? try debug($this->data);die(); if you dont have a debugger. Cake is right by telling you its not empty cause it contains an array of $_FILE['field'] so it is ALWAYS not empty. Use custom validation to check if ['Remarks']['tmp_name'] is not empty, ['error;[ == 0 , and ['size'] != 0 etc HTH, Marcin Domanski aka kabturek http://tumble.kabturek.info/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---