public function bulk_upload() { if ($this->template->is_ajax()) { $files = $_FILES['files']; // if($files['type'][0] != 'text/csv') { // echo json_encode(array( // 'succes' => false, // 'error' => array( // 'message' => 'Wrong file type.' // ) // )); // } else { $this->load->helper('bulk_upload_helper'); $answer = Bulk_upload::getScheduledPostsArray($files['tmp_name'][0], $this->c_user->id, $this->profile->id); if (!$answer['success']) { echo json_encode(array('success' => false, 'error' => array('message' => $answer['error']))); } else { foreach ($answer['data'] as $post) { if (!Social_post::checkPostByDescription($post['description'])) { $this->load->library('Socializer/socializer'); Social_post::add_new_post($post, $this->c_user->id, $this->profile->id); } } echo json_encode(array('success' => true)); } // } } }