Welcome Guest, Not a member yet? Register   Sign In
Form Validation & Upload Libraries are clashing need help.
#1

[eluser]Lamonte[/eluser]
Basically, if I don't fill in the input box, I get both errors, no file selected and this field is required:

Code:
public function add()
    {
        $config['upload_path'] = './uploads/'; //str_replace("\\","/",BASEPATH . 'uploads/');
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '100';
        $config['max_width'] = '1024';
        $config['max_height'] = '768';
        $this->instance->upload->initialize($config);
        $this->form_validation->set_rules('name', 'Project Name', 'required');
        if( !$this->instance->upload->do_upload() && ( $this->form_validation->run() == FALSE))
        {
            $this->template->load( array(
                array(
                    "admin/modules/folio/add",
                    array('upload' => $this->instance->upload->display_errors()),
                ),
            ),"admin");
        }
        else
        {
            //save data in db
        }
    }

When I fill in the input box, not the file input, it submits successfully, yet I didn't even select a file to upload...

Code:
<?php echo anchor("/admin/module/folio/","Manage Projects"); ?> | <?php echo anchor("/admin/module/folio/add","Add Project"); ?>
<h2>Add Project</h2>
&lt;?php echo $upload; ?&gt;
&lt;?php echo validation_errors(); ?&gt;
&lt;?php echo form_open_multipart("admin/module/folio/add"); ?&gt;
<table width='100%' cellspacing='2' cellpadding='2'>
    <tr>
        <td width='30%'>Project Name (Website)</td>
        <td>&lt;?php echo form_input(array('name' => 'name')); ?&gt;</td>
    </tr>
    <tr>
        <td>Preview IMG <small>500x300 px</small></td>
        <td>&lt;input type="file" name="userfile" size="20" /&gt;&lt;/td>
    </tr>
    <tr>
        <td>Service: <small>Designed?</small></td>
        <td>&lt;?php echo form_checkbox(array('name' => 'design')); ?&gt;</td>
    </tr>
    <tr>
        <td>Service: <small>Created Logo?</small></td>
        <td>&lt;?php echo form_checkbox(array('name' => 'logo')); ?&gt;</td>
    </tr>
    <tr>
        <td>Service: <small>(X)HTML?</small></td>
        <td>&lt;?php echo form_checkbox(array('name' => 'xhtml')); ?&gt;</td>
    </tr>
    <tr>
        <td>Service: <small>CSS?</small></td>
        <td>&lt;?php echo form_checkbox(array('name' => 'css')); ?&gt;</td>
    </tr>
    <tr>
        <td>Service: <small>PHP?</small></td>
        <td>&lt;?php echo form_checkbox(array('name' => 'php')); ?&gt;</td>
    </tr>
    <tr>
        <td colspan='2'>&lt;?php echo form_submit("submit","Add Project"); ?&gt;</td>
    </tr>
</table>    
&lt;?php echo form_close(); ?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB