Не загружаются фото в базу данных, как решить?
Вроде всё пишу правильно, но фото не загружается в бд. Как решить эту проблему?
//контроллер
<?php
defined('BASEPATH') OR exit("No direc script access allowed");
class Photos extends MY_Controller {
public function __construct() {
parent::__construct();
$this->load->model('photo_model');
}
public function index() {
$data['title'] = 'Все новости';
$this->load->view('templeates/header', $data);
$this->load->view('news/index', $data);
$this->load->view('templeates/footer');
}
public function createPhoto() {
$data['title'] = 'Все новости';
if($this->input->post('poster') && $this->input->post('slug')) {
$post = $this->input->post('poster');
$slug = $this->input->post('slug');
if($this->news_model->setUpdate($post, $slug)) {
$this->load->view('templeates/header', $this->data);
$this->load->view('news/success', $this->data);
$this->load->view('templeates/footer');
} else {
$this->load->view('templeates/header', $this->data);
$this->load->view('photo/photo_avatar', $this->data);
$this->load->view('templeates/footer');
}
}
}
}
//model
<?php
class Photo_model extends CI_Model {
public function __construct() {
$this->load->database();
}
public function setUpdate($post, $slug) {
$data = array(
'poster' => $post,
'slug' => $slug
);
return $this->db->insert('information', $data);
}
public function getPhoto($slug = FALSE, $limit) {
if ($slug === FALSE) {
$query = $this->db
->order_by('id')
->limit($limit)
->get('information');
return $query->result_array();
}
$query = $this->db->get_where('information', array('slug' => $slug));
return $query->row_array();
}
}
//форма
<form action="/photo/photo_avatar/" method="post">
<input type="input" name="poster" placeholder="poster">
<input type="input" name="slug" placeholder="slug">
<input type="submit" name="submit" value="Отправить">
</form>
//Форма подгружается в меню