CodeIgniter Forums

Full Version: problem with insert upload file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)";
$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'];
$ids = implode(',', $files);
$this->db->set('image', implode(', ',$files));