1 回答

TA贡献1818条经验 获得超7个赞
$this->upload->do_upload('files');true如果文件上传正确则返回。你想要的可能是$this->upload->data()。另外,我建议更改文件名(不是必需的,但有助于调试)。下面是关于这个问题的工作代码 -
for($i = 0; $i < count($_FILES['files']['name']); $i++){
$_FILES['user_file']['name'] = $_FILES['files']['name'][$i];
$_FILES['user_file']['type'] = $_FILES['files']['type'][$i];
$_FILES['user_file']['tmp_name'] = $_FILES['files']['tmp_name'][$i];
$_FILES['user_file']['error'] = $_FILES['files']['error'][$i];
$_FILES['user_file']['size'] = $_FILES['files']['size'][$i];
$fileName = 'user_file';
}
$config['upload_path'] = 'your-path-here';
$config['allowed_types'] = 'gif|jpg|jpeg|png|GIF|JPG|PNG|JPEG';
$config['max_size'] = 6096;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
$this->upload->initialize($config);
$uploaded = $this->upload->do_upload($fileName);
if ( ! $uploaded ){
$error = array('error' => $this->upload->display_errors());
}else{
$upload_data = $this->upload->data(); // You'll get all the data of the uploaded file here.
$file = $upload_data['file_name'];
}
看看是否对你有帮助。
- 1 回答
- 0 关注
- 120 浏览
添加回答
举报