1 回答
TA贡献1884条经验 获得超4个赞
您可以将图像上传到名为“Uploads”的文件夹中,并将该文件名保存到数据库中,如下所示:
视图.php:
<input class="my-set_3" type="file" name="chatbot_profile" id="chatbot_profile" required>
控制器.php:
if (!empty($_FILES['chatbot_profile']['name']))
{
$config['upload_path'] = './uploads';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1000000;
$config['file_name'] = time();
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('chatbot_profile'))
{
$error = array('error' => $this->upload->display_errors());
}
else
{
$data = array('upload_data' => $this->upload->data());
$file_name = $data['upload_data']['file_name'] ;
// Store this filename into database
// Your database code will be placed here
// OR call model mathod from here
}
}
注意:uploads 文件夹将由我们在应用程序文件夹之外创建
- 1 回答
- 0 关注
- 128 浏览
添加回答
举报