11-14-2016, 05:50 PM
i have problem with my implode function when i try to insert just one line with come it always store many lines need helps this is my code
$config["upload_path"] = $this->upload_path;
$config["allowed_types"] = "jpg|jpeg|png|gif";
$config['file_name'] = $_FILES['file']['name'];
$files = [];
$ids = '';
foreach ($_FILES as $key => $value) {
if (!empty($value['name'])) {
$this->load->library('upload', $config);
if (!$this->upload->do_upload($key)) {
echo "failed to upload file(s)";
}
else{
$fileData = $this->upload->data();
//$files[$i] = $this->upload->data();
//$file [] = $files[$i]['file_name'];
$files[] = $fileData['file_name'];
//$file = $dir_path . $files[$i]['file_name'];
//++$i;
}
}
}
if(is_array($files)){
$ids = implode(',', $files);
$this->db->set('image', implode(', ',$files));
$this->db->insert('annonce');
}
$config["upload_path"] = $this->upload_path;
$config["allowed_types"] = "jpg|jpeg|png|gif";
$config['file_name'] = $_FILES['file']['name'];
$files = [];
$ids = '';
foreach ($_FILES as $key => $value) {
if (!empty($value['name'])) {
$this->load->library('upload', $config);
if (!$this->upload->do_upload($key)) {
echo "failed to upload file(s)";
}
else{
$fileData = $this->upload->data();
//$files[$i] = $this->upload->data();
//$file [] = $files[$i]['file_name'];
$files[] = $fileData['file_name'];
//$file = $dir_path . $files[$i]['file_name'];
//++$i;
}
}
}
if(is_array($files)){
$ids = implode(',', $files);
$this->db->set('image', implode(', ',$files));
$this->db->insert('annonce');
}