Welcome Guest, Not a member yet? Register   Sign In
form_open_multipart with form_validation - am I missing something or is it a bug ?
#1

[eluser]DeaD SouL[/eluser]
Hello

This example doesn't want to work..
It keeps saying
Quote:The File field is required.
even if I removed the validation rule, it just show me the form again and again..

Am I missing something here ?

CI ver: 2.0.2

controller:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Test_files extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $this->load->library( 'form_validation' );
        $this->form_validation->set_rules( 'inp_file', 'File', 'required' );
        
        if( $this->form_validation->run() === FALSE )
        {
            $this->load->view( 'test_files' );
        }
        else
        {
            echo '<pre>', print_r( $_FILES, TRUE ), '</pre>';
        }
    }
}


view:
Code:
<!DOCTYPE html>
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="utf-8"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?=form_open_multipart( $this->uri->uri_string() );?&gt;
    <div id="infoMessage">&lt;?=validation_errors();?&gt;</div>
    &lt;?=form_label('File: ', 'inp_file') . form_upload('inp_file', '', 'id="inp_file"');?&gt;
    &lt;?=form_submit('submit', 'Upload');?&gt;
&lt;?=form_close(); ?&gt;
&lt;/body&gt;
&lt;/html&gt;

Thanks


Messages In This Thread
form_open_multipart with form_validation - am I missing something or is it a bug ? - by El Forum - 05-31-2011, 08:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB