введите описание изображения здесь Я хочу загрузить свои изображения в каталог загрузки, но, когда я отправляю запрос на публикацию, нажимая кнопку «Отправить», кажется, что мой код запускается, но он не вставляет переданное изображениевместо этого в каталог для загрузки он запускает код, приведенный ниже
if (!$this->upload->do_upload()) {
$errors = array('error' => $this->upload->display_errors());
$post_image = 'no_image.jpg';
}
, в результате чего он отображает no_image.jpg в моей базе данных.Итак, я попытался отредактировать его, но кажется, что код не может быть загружен, поэтому мне интересно, что может быть не так с моим кодом.
Это часть моего файла контроллера.
public function Edit_RoomType()
{
$data['title'] = 'Rooms_model';
$this->form_validation->set_rules('room','RoomType','required');
$this->form_validation->set_rules('Amount','Price Tag','required');
if ($this->form_validation->run() === FALSE) {
$this->load->view('templates/header_Admin');
$this->load->view('Admin/Edit_RoomType', $data);
$this->load->view('templates/footer_Admin');
} else {
//image upload
$config['upload_path'] ='./assets/uploads';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] ='2048';
$config['max_width'] ='500';
$config['max_height'] ='500';
$this->load->library('upload', $config);
if (!$this->upload->do_upload()) {
$errors = array('error' => $this->upload->display_errors());
$post_image = 'no_image.jpg';
} else {
$data = array('upload_data' => $this->upload->data());
//setting table field
$post_image = $_FILES['userfile']['name'];
}
$this->Rooms_model->create_room($post_image);
redirect('Admin');
}
}
нижеявляется частью файла моей модели
public function create_room($post_image)
{
$Room_type = url_title($this->input->post('room'));
$data = array(
'Room_type' => $Room_type,
'Amount' => $this->input->post('Amount'),
'description' => $this->input->post('description'),
'post_image' => $post_image
);
return $this->db->insert('RoomType',$data);
}