Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Unggah banyak gambar dengan Codeigniter hanya menyimpan satu jalur file ke Database MySQL

Oke beberapa perubahan kecil mungkin bisa membantu

public function post(){        
    if($this->_validation()===FALSE){ 
        $this->session->set_flashdata('error', 'Ooops, there was an error');
        redirect(base_url("admin/product"));
    }else{
        $files = $_FILES;
        $images = array();
        $cpt = count($_FILES['userfile']['name']);
            for($i=0; $i<$cpt; $i++){
            $_FILES['userfile']['name']= $files['userfile']['name'][$i];
            $_FILES['userfile']['type']= $files['userfile']['type'][$i];
            $_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name'][$i];
            $_FILES['userfile']['error']= $files['userfile']['error'][$i];
            $_FILES['userfile']['size']= $files['userfile']['size'][$i];
            $this->upload->initialize($this->set_upload_options());
            $this->upload->do_upload();
            $images[] = $_FILES['userfile']['name'];
        }
        $fileName = implode(',',$images);

        $data = array(  'kodeProduk'                => $this->input->post('kodeproduk'),
                        'ket'                       => $this->input->post('ket'),

                        'GambarBesar'               => $fileName
        );

        unset($data['submit']);                             
        $this->table->add_record($data);
        $this->session->set_flashdata('success', 'Product has been saved.');
        redirect(base_url("admin/product"));
    }   
}


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. MySQL memicu sintaks 'perbarui pada kolom'

  2. Koneksi MySQL tidak berfungsi

  3. Laravel 5:menyinkronkan bidang tambahan melalui pivot

  4. Batalkan permintaan AJAX yang tertunda di aplikasi PHP?

  5. Impor dan masukkan file sql.gz ke database dengan dempul