Hallo! Selamat Datang di Marketplace produk digital, Freelancer terbaik di indonesia (68414 Members, 793 Products, 5353 Topic, 13045 Comments)

Multiple Upload - Upload Lebih Dari 1 File Gambar Codeigniter

Dibuat
Login Terakhir 2 Tahun lalu,
Telah Dilihat 8235 Kali
Budi Darma Mengatakan : Sultan Account
  1. #ask
  2. Mhn bantuannya untuk insert gambar lebih dari 1 ke 1 tabel jadi field nya
  3. id_cus | gambar1 |gambar2
  4.  
  5. Dengan codeigniter

Ada 4 Jawaban

Bukhori Muslim
commented on 08 Nov 2018 09:48:11
  1. Assalam,.. seperti ini caranya gan :
  2.  
  3. File 1 <input type="file" name="userfile">
  4. Fiel 2 <input type="file" name="userfile2">
  5.  
  6. public function save() {
  7. $data = array();
  8. $config['upload_path'] = './uploads/';
  9. $config['allowed_types'] = 'jpg|png';
  10. $config['max_size'] = 5024;
  11. $config['encrypt_name'] = true;
  12.  
  13. $this->load->library('upload', $config);
  14.  
  15. if (!$this->upload->do_upload('userfile')) {
  16. $error = array('error' => $this->upload->display_errors());
  17. } else {
  18. $fileData = $this->upload->data();
  19. $data['userfile'] = $fileData['file_name'];
  20. }
  21.  
  22. if (!$this->upload->do_upload('userfile2')) {
  23. $error = array('error' => $this->upload->display_errors());
  24. } else {
  25. $fileData = $this->upload->data();
  26. $data['userfile2'] = $fileData['file_name'];
  27. }
  28. }
fatkhurrochman
commented on 23 Jul 2019 14:15:15
  1. saya sudah coba cara di atas.
  2. image berhasi terupload tp tidak bisa masuk ke database mas.
  3. mohon pencerahannya.
Alvian Bagaswara
commented on 29 Agu 2019 22:51:01
  1. cuma membantu, tambahkan return di array data nya bang.
  2. if (!$this->upload->do_upload('userfile')) {
  3. $error = array('error' => $this->upload->display_errors());
  4. } else {
  5. $fileData = $this->upload->data();
  6. return $data['userfile'] = $fileData['file_name'];
  7. }
  8.  
  9. if (!$this->upload->do_upload('userfile2')) {
  10. $error = array('error' => $this->upload->display_errors());
  11. } else {
  12. $fileData = $this->upload->data();
  13. return $data['userfile2'] = $fileData['file_name'];
  14. }
pramadians
commented on 03 Sep 2020 09:45:58
  1. Assalamualaikum,.. Bagaimana jika nama file di folder upload (direktori temporer) berbeda dengan nama file yg terinput di database. contohnya : nama file di database " gbr1.jpg" di folder upload " ef75cfabf44a93d12ac528ec8e5261ad.jpg"
Maaf, Untuk Memberikan Komentar Anda Harus Login !!!

Online