我正在尝试通过codeigniter上传图片,但不断收到以下消息:“您没有选择要上传的文件”。
我已经看过很多关于此的答案,但没有任何帮助:
HTML:
<h3>Upload profile image</h3>
<div data-role="fieldcontainer">
<form action='do_upload_prof' method='post' enctype="multipart/form-data">
<input type="file" name='file'>
<input type='submit' value='upload' />
</form>
</div>
PHP控制器:
public function do_upload_prof() {
$config = array(
'upload_path' => "./profile_img/",
'allowed_types' => "gif|jpg|png|jpeg",
'overwrite' => TRUE,
'max_size' => "4048000",
'max_height' => "768",
'max_width' => "1024"
);
$this->load->library('upload', $config);
if ($this->upload->do_upload('file')) {
$data = array(
'upload_data' => $this->upload->data()
);
$this->load->view('header');
$this->load->view('profile', $data);
$this->load->view('footer');
} else {
$error = array(
'error' => $this->upload->display_errors()
);
$this->load->view('header');
$this->load->view('profile', $error);
$this->load->view('footer');
}
}