[eluser]mrmeyers99[/eluser]
The rule for this field is in my form_validation:
Code:
$this->form_validation->set_rules('new_reminders', 'New Reminders','callback_isValidFile');
Here is the isValidFile function
Code:
$config['upload_path'] = './reminders/';
$config['allowed_types'] = 'zip';
$this->load->library('upload', $config);
if ( !$this->upload->do_upload('new_reminders'))
{
$data = $this->upload->data();
// For testing, print this out
print_r($data);
print_r($_POST);
echo 'input'.$this->input->post('new_reminders');
// if reminder_package isn't set, new_reminders is required
if ($this->input->post('reminder_package') == '' && $data['file_name'] == '')
{
$this->form_validation->set_message('isValidFile', 'The reminder package field is required.');
return FALSE;
}
// if reminder_package is set, and new_reminders wasn't, that's ok too
else if ($this->input->post('reminder_package') != '' && $data['file_name'] == '')
{
// Normally this would return TRUE, but for testing purposes:
$this->form_validation->set_message('isValidFile', 'whatever');
return FALSE;
}
// Otherwise, show errors
$this->form_validation->set_message('isValidFile', $this->upload->display_errors());
return FALSE;
}
else
{
return TRUE;
}
View:
Code:
<?=form_open_multipart('controller/function')?>
<td>New File:</td>
<td><?=form_upload('new_reminders')?></td>
<td><?=form_error('new_reminders')?></td>
<?=form_close()?>