I have code for uploading multiple images, it is returning the word "ARRAY"
, not return the content when I make " echo , die;"
, and in the other ways it return just the first upload and inserted into database.
I want to insert multiple value "IMGE"
in single row database.
Controller:
function uploadFile(){
$data = array();
// If file upload form submitted
if($this->input->post('Submit') && !empty($_FILES['files']['name']))
{
$filesCount = count($_FILES['files']['name']);
for($i = 0; $i < $filesCount; $i++){
$_FILES['file']['name'] = $_FILES['files']['name'][$i];
$_FILES['file']['type'] = $_FILES['files']['type'][$i];
$_FILES['file']['tmp_name'] = $_FILES['files']['tmp_name'][$i];
$_FILES['file']['error'] = $_FILES['files']['error'][$i];
$_FILES['file']['size'] = $_FILES['files']['size'][$i];
// File upload configuration
$uploadPath = 'uploads/files/';
$config['upload_path'] = $uploadPath;
$config['allowed_types'] = 'jpg|jpeg|png|gif';
// Load and initialize upload library
$this->load->library('upload', $config);
$this->upload->initialize($config);
// Upload file to server
if($this->upload->do_upload('file')){
// Uploaded file data
///////////////////////////////////////////
//HERR I WANT TO RETURN THE - $file[$i] - WITH ALL
//THE IMAGE UPLAD TO INSER IN SINGLE ROW IN DATABASE
///////////////////////////////////////////
$fileData = $this->upload->data();
$uploadData[$i]['file_name'] = $fileData['file_name'];
$uploadData[$i]['uploaded_on'] = date("Y-m-d H:i:s");
$file[$i] = $uploadData[$i]['file_name'];
return $file[$i];
echo $file[$i] , die; // here it is just return first image upload
}
}
if(!empty($uploadData)){
return $uploadData;
echo $new_array, die;// here it is return word "ARRAY"}}
Model:
function insert_data($data) // from one table
{
$insert = $this->db->insert('tbl_reservations', $data);
}