Welcome Guest, Not a member yet? Register   Sign In
Problems with multiple files

Hello guys,
I have a problem to climb multiple files.
I researched and found a few ways to climb several files.
Occurs that need rescuing file names to insert them in certain fields in a table.
If anyone can to help, thank you.

My Table Services
id int(10)
desc varchar(30)
espec text
img00 varchar(45)
img01 varchar(45)
img02 varchar(45)
img03 varchar(45)

// My view
echo form_open_multipart(base_url().'admin/services/add');
    echo form_fieldset("Test");
    echo '<table class="table">';
                echo '<tbody>';
                echo '<tr>';
                echo '<td>';
  echo form_label('Title');
  echo '&lt;input type="text" name="desc"&gt;';
                echo '</td>';
                echo '<td>';
                echo form_label('Principal Image', 'userfile');
  echo form_upload('userfile');
                echo '</tr>';
                echo '</tbody>';
                echo '</table>';
                echo '<table class="table">';
                echo '<tbody><tr>';
                echo '<td>';
  echo form_label('Espec');
                echo '&lt;textarea name="espec"&gt;';
                echo '&lt;/textarea&gt;';
                echo '</td>';
                echo '<td>';
                echo form_label('Image 01', 'img01');
  echo form_upload('img01');                
                echo form_label('Image 02', 'img02');
  echo form_upload('img02');                
                echo form_label('Image 03', 'img03');
  echo form_upload('img03');                
                echo '</td>';
                echo '</tr></tbody></table>';
                echo form_submit('mysubmit','Add');
                echo form_reset('myreset','Cancel');
                echo form_fieldset_close();
                echo form_close();

// My Controler Sevices

    function add(){
        $config = array(
            array('field' =>'desc','label' =>'Title','rules' =>'required'),
            array('field' =>'espec','label' =>'Espec','rules' =>'required')
   if ($this->form_validation->run() == FALSE){
   else {
    $config['upload_path'] = 'assets/img/services';  
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size'] = 0;
    $config['max_width']  = 600;
    $config['max_height']  = 400;
    $config['encrypt_name'] = TRUE;
    $this->load->library('upload', $config);
    echo $this->upload->display_errors();
    else {
     $image0 = $this->upload->data();
     $dados['img00'] = $image0['file_name'];
     $image1 = $this->upload->data();
     $dados['img01'] = $image1['file_name'];
     $image2 = $this->upload->data();
     $dados['img02'] = $image2['file_name'];
     $image3 = $this->upload->data();
     $dados['img03'] = $image3['file_name'];
     $dados['desc'] = $this->input->post('desc');
     $dados['espec'] = $this->input->post('espec');            
     if ($this->services_model->add($dados)){
      redirect(base_url().'admin/services/', 'refresh');
     else {
      echo 'Error';

// My Model

class Services_model extends CI_Controller{
    function __construct() {

    function add($dados){
        return $this->db->insert('services',$dados);

Theme © iAndrew 2016 - Forum software by © MyBB