Multiple Upload - Upload Lebih Dari 1 File Gambar CodeigniterDibuat
Login Terakhir
1 Tahun lalu,
Telah Dilihat 9122 Kali
| |
Sultan Account |
|
|
Budi Darma
Mengatakan :
Sultan Account
#ask Mhn bantuannya untuk insert gambar lebih dari 1 ke 1 tabel jadi field nya id_cus | gambar1 |gambar2 Dengan codeigniter |
|
| Bukhori Muslim commented on 08 Nov 2018 09:48:11 Sultan Account |
|
|
|
Assalam,.. seperti ini caranya gan :
File 1 <input type="file" name="userfile">
Fiel 2 <input type="file" name="userfile2">
public function save() {
$data = array();
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = 5024;
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile')) {
$error = array('error' => $this->upload->display_errors());
} else {
$fileData = $this->upload->data();
$data['userfile'] = $fileData['file_name'];
}
if (!$this->upload->do_upload('userfile2')) {
$error = array('error' => $this->upload->display_errors());
} else {
$fileData = $this->upload->data();
$data['userfile2'] = $fileData['file_name'];
}
} |
|
| fatkhurrochman commented on 23 Jul 2019 14:15:15Free Account |
|
|
|
saya sudah coba cara di atas. image berhasi terupload tp tidak bisa masuk ke database mas. mohon pencerahannya. |
|
| Alvian Bagaswara commented on 29 Agu 2019 22:51:01Free Account |
|
|
|
cuma membantu, tambahkan return di array data nya bang.
if (!$this->upload->do_upload('userfile')) {
$error = array('error' => $this->upload->display_errors());
} else {
$fileData = $this->upload->data();
return $data['userfile'] = $fileData['file_name'];
}
if (!$this->upload->do_upload('userfile2')) {
$error = array('error' => $this->upload->display_errors());
} else {
$fileData = $this->upload->data();
return $data['userfile2'] = $fileData['file_name'];
} |
|
| pramadians commented on 03 Sep 2020 09:45:58 Sultan Account |
|
|
|
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" |
|