Haloo! Selamat Datang di Komunitas Private Training Web Development (57122 Members, 641 Products, 4568 Topic, 12025 Comments)

Butuh karyawan baru? atau seorang Web Developer (Part-time/Freelance/Full-time), cari disini : Members Area Jobs!

Membuat Produt Detail Pada Web Online Shop + COD

Dibuat
Login Terakhir 5 Bulan lalu,
Telah Dilihat 255 Kali
M IQBAL AR Mengatakan : Premium
  1. Assalamualaikum Warahmatullahi Wabarakatuh...
  2.  
  3. saya ingin tanya untuk web onlineshop + cod
  4. saya ingin membuat dalam produk bisa memuat banyak foto .
  5.  
  6. apa yang harus saya rubah ?
  7.  
  8. Terima kasih
  9.  

Ada 4 Jawaban

PHPMU.COM Support
commented on 08 Feb 2020 07:23:47
  1. Assalamualaikum,.. berikut tahapannya :
  2. 1. baca Bismillah..
  3. 2. ubah type inputan file menjadi multiple pada file :
  4. application\views\administrator\mod_produk\view_produk_tambah.php baris ini :
  5. <input type='file' class='form-control' name='g'> menjadi :
  6. <input type='file' class='form-control' name='userfile[]' multiple>
  7.  
  8. Lalu pada action simpan gambar pada controllers tambah_produk() ubah menjadi :
  9. function tambah_produk(){
  10. cek_session_akses('produk',$this->session->id_session);
  11. if (isset($_POST['submit'])){
  12. $files = $_FILES;
  13. $cpt = count($_FILES['userfile']['name']);
  14. for($i=0; $i<$cpt; $i++){
  15. $_FILES['userfile']['name']= $files['userfile']['name'][$i];
  16. $_FILES['userfile']['type']= $files['userfile']['type'][$i];
  17. $_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name'][$i];
  18. $_FILES['userfile']['error']= $files['userfile']['error'][$i];
  19. $_FILES['userfile']['size']= $files['userfile']['size'][$i];
  20. $this->load->library('upload');
  21. $this->upload->initialize($this->set_upload_options());
  22. $this->upload->do_upload();
  23. $fileName = $this->upload->data()['file_name'];
  24. $images[] = $fileName;
  25. }
  26. $fileName = implode(';',$images);
  27. $fileName = str_replace(' ','_',$fileName);
  28.  
  29. if (trim($fileName)!=''){
  30. $data = array('id_kategori_produk'=>$this->input->post('a'),
  31. 'nama_produk'=>$this->db->escape_str($this->input->post('b')),
  32. 'produk_seo'=>$this->db->escape_str(seo_title($this->input->post('b'))),
  33. 'satuan'=>$this->input->post('c'),
  34. 'harga_beli'=>$this->input->post('d'),
  35. 'harga_reseller'=>$this->input->post('e'),
  36. 'harga_konsumen'=>$this->input->post('f'),
  37. 'berat'=>$this->input->post('berat'),
  38. 'gambar'=>$fileName,
  39. 'keterangan'=>$this->input->post('ff'),
  40. 'username'=>$this->session->username,
  41. 'waktu_input'=>date('Y-m-d H:i:s'));
  42. }else{
  43. $data = array('id_kategori_produk'=>$this->input->post('a'),
  44. 'nama_produk'=>$this->input->post('b'),
  45. 'produk_seo'=>$this->db->escape_str(seo_title($this->input->post('b'))),
  46. 'satuan'=>$this->input->post('c'),
  47. 'harga_beli'=>$this->input->post('d'),
  48. 'harga_reseller'=>$this->input->post('e'),
  49. 'harga_konsumen'=>$this->input->post('f'),
  50. 'berat'=>$this->input->post('berat'),
  51. 'keterangan'=>$this->input->post('ff'),
  52. 'username'=>$this->session->username,
  53. 'waktu_input'=>date('Y-m-d H:i:s'));
  54. }
  55. $this->model_app->insert('rb_produk',$data);
  56. redirect('administrator/produk');
  57. }else{
  58. $data['record'] = $this->model_app->view_ordering('rb_kategori_produk','id_kategori_produk','DESC');
  59. $this->template->load('administrator/template','administrator/mod_produk/view_produk_tambah',$data);
  60. }
  61. }
  62.  
  63. Lalu tambahkan config uploadnya gambar dibawahnya :
  64. private function set_upload_options(){
  65. $config = array();
  66. $config['upload_path'] = "asset/foto_produk/";
  67. $config['allowed_types'] = 'gif|jpg|png|jpeg|JPG|JPEG|PNG|GIF';
  68. $config['max_size'] = '10000'; // kb
  69. $config['encrypt_name'] = FALSE;
  70. $this->load->library('upload', $config);
  71. return $config;
  72. }
  73.  
  74. Selesai, tinggal menampilkan gambar pada halaman web utama jadinya begini :
  75. $ex = explode(';',$row['gambar']);
  76. $hitungex = count($ex);
  77. for($i=0; $i<$hitungex; $i++){
  78. echo "<img src='".base_url()."asset/foto_produk/".$ex[$i]."'>";
  79. }
M IQBAL AR
commented on 11 Feb 2020 15:15:11
  1. Assalamualaikum,..
  2.  
  3. kalau scriptnya saya sudah bisa pak, cuman masalah untuk di web utamanya untuk geser gambarnya itu
PHPMU.COM Support
commented on 11 Feb 2020 15:46:43
  1. Assalamualaikum,.. maaf, maksudnya geser gimana mas?
M IQBAL AR
commented on 13 Feb 2020 07:10:34
  1. Assalamualaikum,.. seperti ini pak https://bootsnipp.com/snippets/56bAW
Maaf, Untuk Memberikan Komentar Anda Harus Login !!!