将项目文件更新为最新版本的Codeigniter后,当我上载任何文件时,它将返回以下错误:
代码如下:
public function test_upload(){
$config = array(
'upload_path' => './assets/upload_test',
'allowed_types' => 'gif|jpg|png|jpeg|pdf',
'max_size' => '2048',
);
if($_FILES['file']['name'] != '')
{
$image = 'file';
$upload_data = $this->do_upload($image, $config);
if($upload_data['condition']=='error')
{
echo json_encode(array('condition'=>'error', 'message'=>$upload_data['error'].' (User image)')); exit;
}else{
$profile_picture['file'] = $upload_data['upload_data']['file_name'];
}
}
print_r($profile_picture);exit;
}
public function do_upload($image, $config)
{
$this->load->library('upload');
$this->upload->initialize($config);
if ( ! $this->upload->do_upload($image))
{
$error = array('condition'=>'error', 'error' => $this->upload->display_errors());
return $error;
}
else
{
$data = array('condition'=>'success', 'upload_data' => $this->upload->data());
return $data;
}
}
搜索了很多,但没有找到任何好的解决方案。谢谢大家的回复。