CodeIgniter Forums

Full Version: image form validation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum


I created a callback validation for the files uploaded by a form.
here the code:

function userfile_check(){
            $ff = $_FILES['userfile'];
                $this->form_validation->set_message('userfile_check', 'Image required');
                return FALSE;
            $extension= end(explode(".", $ff['name']));
            $ext = array('jpg','png');
                $this->form_validation->set_message('userfile_check', 'Image not valid');
                return FALSE;
            $this->form_validation->set_message('userfile_check', 'Image required');


    function add() {


        $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