1 回答

TA貢獻1884條經(jīng)驗 獲得超4個贊
您可以將圖像上傳到名為“Uploads”的文件夾中,并將該文件名保存到數(shù)據(jù)庫中,如下所示:
視圖.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 文件夾將由我們在應用程序文件夾之外創(chuàng)建
- 1 回答
- 0 關注
- 168 瀏覽
添加回答
舉報