• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File upload validation

#34
[eluser]predat0r[/eluser]
Thanks pistolPete, your solution solved my upload validation! :-P

[quote author="pistolPete" date="1235453832"]Say we have a form which consists of a input field (called "image_title") and one file upload.
Both of them are required to pass the validation.

The rule looks like:
Code:
$this->form_validation->set_rules('image_title', 'Image title', 'trim|required|callback__do_upload');
Code:
// callback function to process the file upload and validate it
function _do_upload($file)
{
    $config['upload_path'] = './folder/';
    $config['allowed_types'] = 'put|your|allowed|types|here';
    $this->load->library('upload', $config);
        
    if ( ! $this->upload->do_upload())
    {
        // set the validation error using the errors provided by the upload class
        $this->form_validation->set_message('_do_upload', $this->upload->display_errors());
        return FALSE;
    }    
    else
    {
        return TRUE;
    }
}
[/quote]


Messages In This Thread
File upload validation - by El Forum - 02-23-2009, 05:24 PM
File upload validation - by El Forum - 02-23-2009, 05:37 PM
File upload validation - by El Forum - 02-24-2009, 06:36 PM
File upload validation - by El Forum - 02-24-2009, 08:20 PM
File upload validation - by El Forum - 02-25-2009, 05:18 AM
File upload validation - by El Forum - 02-25-2009, 05:36 AM
File upload validation - by El Forum - 02-25-2009, 05:40 AM
File upload validation - by El Forum - 02-25-2009, 06:14 PM
File upload validation - by El Forum - 03-22-2009, 11:40 AM
File upload validation - by El Forum - 03-22-2009, 12:23 PM
File upload validation - by El Forum - 03-22-2009, 12:29 PM
File upload validation - by El Forum - 03-22-2009, 03:33 PM
File upload validation - by El Forum - 03-22-2009, 04:07 PM
File upload validation - by El Forum - 03-22-2009, 04:31 PM
File upload validation - by El Forum - 03-22-2009, 04:52 PM
File upload validation - by El Forum - 03-22-2009, 05:00 PM
File upload validation - by El Forum - 03-22-2009, 05:06 PM
File upload validation - by El Forum - 03-28-2009, 09:32 AM
File upload validation - by El Forum - 03-28-2009, 09:37 AM
File upload validation - by El Forum - 03-28-2009, 10:50 AM
File upload validation - by El Forum - 04-11-2009, 11:31 AM
File upload validation - by El Forum - 04-11-2009, 11:44 AM
File upload validation - by El Forum - 04-11-2009, 12:09 PM
File upload validation - by El Forum - 04-11-2009, 12:19 PM
File upload validation - by El Forum - 04-11-2009, 12:33 PM
File upload validation - by El Forum - 04-11-2009, 05:39 PM
File upload validation - by El Forum - 04-12-2009, 02:41 AM
File upload validation - by El Forum - 04-12-2009, 05:08 AM
File upload validation - by El Forum - 04-12-2009, 08:17 AM
File upload validation - by El Forum - 04-12-2009, 10:50 AM
File upload validation - by El Forum - 10-23-2009, 10:09 AM
File upload validation - by El Forum - 10-23-2009, 10:44 AM
File upload validation - by El Forum - 12-23-2010, 10:56 PM
File upload validation - by El Forum - 02-27-2011, 11:10 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.