/ Published in: PHP
                    
                                        
Test controller for custom Form_validation class
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
class Form_test extends Controller
{
/**
* Constructor
*
* @return name
* @access public
*/
public function __construct()
{
parent::Controller();
}
/**
*
*
* @access public
*/
public function index()
{
$this->form_validation->set_rules('user_file', 'User File', 'file_required|valid_file_extension[doc|docx|pdf]');
$this->form_validation->set_rules('first_name', 'First Name', 'trim|required');
if ($this->form_validation->run($this))
{
$first_name = $this->input->post('first_name');
$this->load->library('upload');
'upload_path' => './uploads/',
'allowed_types' => 'doc|docx|pdf',
'overwrite' => TRUE
));
if ($this->upload->do_upload('user_file') === FALSE)
{
$upload_errors = $this->upload->display_errors();
}
else
{
$data['success'] = TRUE;
}
}
$data['form_errors'] = validation_errors();
$data['user_file'] = set_value('user_file', '');
$data['user_file_error'] = form_error('user_file');
$this->load->view('form_test', $data);
}
}
/* End of file name.php */
/* Location: ./system/application/controller/name.php */
Comments
 Subscribe to comments
                    Subscribe to comments
                
                