2 回答

TA贡献1866条经验 获得超5个赞
请替换此代码
$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贡献1876条经验 获得超6个赞
以下是将文件从网站根目录和根目录中的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 关注
- 162 浏览
添加回答
举报