Thursday, May 5, 2011

File Upload

In our blog we allow that a regular user or a admin can upload a file when he is creating a new post. But we want to put some restrictions.
We don't want the user to upload a file without extension, but furthermore we only are going to allow the user to upload a image file.
That's why he have include this rule inside our post method :

'file_name' => array(
  'file_name' =>array(
   'rule' => array('extension', array('gif', 'jpeg', 'png', 'jpg')),
   'message' => 'The file has to be a image file'
   )
   )
That rules indicate that the filename has to have the extension of a image file. That's one of our procedure to validate the data
 

No comments:

Post a Comment