[eluser]Unknown[/eluser]
Hello,
I created a callback validation for the files uploaded by a form.
here the code:
Code:
function userfile_check(){
if(isset($_FILES['userfile'])):
$ff = $_FILES['userfile'];
if(!$ff['name']):
$this->form_validation->set_message('userfile_check', 'Image required');
return FALSE;
endif;
$extension= end(explode(".", $ff['name']));
$ext = array('jpg','png');
if(!in_array($extension,$ext)):
$this->form_validation->set_message('userfile_check', 'Image not valid');
return FALSE;
endif;
else:
$this->form_validation->set_message('userfile_check', 'Image required');
endif;
}
function add() {
$this->load->library('form_validation');
$this->form_validation->set_rules('userfile', 'file', 'callback_userfile_check');
...
}
How can transform userfile_check() for use it in MY_Form_validation.php?
I use an helper for my general functions but also in my helper I can't adapt this code.
Both solutions will be appreciate