0
Ich möchte eine Datei umbenennen, wenn ich diese Datei hochlade. Also der Inhalt der add_land_short sollte den Namen der Datei erhalten. Also wenn der Eingabetest ist, ist die Datei test.png. ControllerDatei beim Hochladen umbenennen
:
public function insert_land()
{
$land_short = $this->input->post('add_land_short');
$config['upload_path'] = './assets/images/site/flag/';
$config['allowed_types'] = '*';
$config['max_size'] = '2048';
$config['max_width'] = '2000';
$config['max_height'] = '2000';
$this->load->library('upload', $config);
if (!$this->upload->do_upload())
{
$errors = array('error' => $this->upload->display_errors());
$post_image = 'noimage.jpg';
}
else
{
$data = array('upload_data' => $this->upload->data());
$post_image = $_FILES['userfile']['name'];
}
$this->Admin_model->insert_land();
redirect('admin/land/');
}
Modell:
public function insert_land()
{
$this->db->where('tb_land_name', $this->input->post('add_land_name'));
$this->db->where('tb_land_kurzel', $this->input->post('add_land_short'));
$this->db->where('tb_land_img', $this->input->post('add_land_short'));
$result = $this->db->get('db_land');
if($result->num_rows() < 1)
{
$data = array( 'tb_land_name' => $this->input->post('add_land_name'),
'tb_land_kurzel' => $this->input->post('add_land_short'),
'tb_land_last_buy' => date('Y-m-d'),
'tb_land_img' => $this->input->post('add_land_short'),
);
return $this->db->insert('db_land', $data);
}
}