public function save_uploaded_contacts($data, $dest_path) { $ObjCUT = new contactsUploadedTempModel(); $rowdata = array(); if (($handle = fopen($dest_path . $data['filename'], "r")) !== FALSE) { while (($col = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($col) { $x = 1; $rowdata['contact_id'] = $data['contact_id']; foreach ($col as $value) { $rowdata['column' . $x] = $value; $x++; } $ObjCUT->insert_data($rowdata); } } fclose($handle); } }