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 關注
- 145 瀏覽
添加回答
舉報