im using the below code to upload multiple images, take the image file name, concatenate with “,” and return the value so it can be used to insert into the database using CodeIgniter.
The problem that im having is im unable to concatenate the file names using implode().
Can someone please tell me what am i doing wrong?
function upload(){
$config['upload_path'] = './uploadsim/';
$config['allowed_types'] = 'gif|jpg|jpeg';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$this->load->library('upload', $config);
for($i = 1; $i < 6; $i++) {
$upload = $this->upload->do_upload('image'.$i);
if($upload === FALSE) continue;
$images = array('upload_data'=>$this->upload->data());
$imagename= $images['upload_data']['file_name'];
$impl= implode(",", $imagename);
}
return $impl;
}
change the notation on image name to build up an array
then move your implode to outside of the loop