2 回答

TA貢獻(xiàn)1866條經(jīng)驗(yàn) 獲得超5個(gè)贊
請(qǐng)?zhí)鎿Q此代碼
$config['upload_path'] = './assets/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('pic_file'))
{
$error = array('error' => $this->upload->display_errors());
print_r($error);
}
else
{
$data = array('upload_data' => $this->upload->data());
print_r($data);
}
die;

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超6個(gè)贊
以下是將文件從網(wǎng)站根目錄和根目錄中的uploadFolder上傳到所需文件夾的通用代碼。
/*------------------------ File Upload --------------------------- */
$config['upload_path'] = './uploadFolder/';
$config['allowed_types'] = 'pdf|jpg|jpeg|png';
$this->load->library('upload', $config);
$filename = "";
if (!$this->upload->do_upload('filename')) {
//$this->session->set_flashdata('error_msg', $this->upload->display_errors());
} else {
$data1 = array('upload_data' => $this->upload->data());
$filename = "" . $data1["upload_data"]["file_name"];
}
$filename is the Filename required to store in the database
- 2 回答
- 0 關(guān)注
- 183 瀏覽
添加回答
舉報(bào)