Welcome Guest, Not a member yet? Register   Sign In
form validation - show upload errors

I'd like some help please.

I', having a contact form in which I can also upload files. I have set up the form validation and the uploading configuration according to the documentation, however I have spotted a "logic" problem.

If I submit all the form fields with valid data and select an invalid type file to upload, the form process works as correct, and redirects to my "thank you" page, whereas I should get the error message from the invalid file upload. I 'm assuming this is because the upload errors are not part of the form_validation library or the two libraries don't "communicate" some way.

How can I fix this bug ?

This is my code

PHP Code:
protected $rules = array(
'name' => array(
'field' => 'name',
'label' => 'Name',
'rules' => 'trim|required|min_length[2]',
'email' => array(
'field' => 'email',
'label' => 'Email address',
'rules' => 'trim|required|valid_email',
'phone' => array(
'field' => 'phone',
'label' => 'Phone number',
'rules' => 'trim|required',
'comments' => array(
'field' => 'comments',
'label' => 'Comments',
'rules' => 'trim|required|min_length[10]',

// in my method, where I run the validation
if ($topic == 'Employment query' && count($_FILES)) {
$config['max_size'] = '5000';
$config['upload_path'] = 'content/cvs';
$config['allowed_types'] = 'doc|docx|pdf|odt';

    if (
$this->upload->do_upload('upload_cv')) {
$cv_file $this->upload->data();
    else {
$this->data['upload_error'] = $this->upload->display_errors('<span class="help-block">''</span>');

if (
$this->form_validation->run()) {
// get form data and send email


Messages In This Thread
form validation - show upload errors - by Lykos22 - 10-14-2015, 08:29 AM

Theme © iAndrew 2016 - Forum software by © MyBB