使用 CodeIgniter 2.1.4,我正在尝试使用 ajax 和文件上传类上传文件。我在控制器中的构造为:
public function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
我在控制器中的上传功能为:
public function upload_file()
{
$config['upload_path'] = 'upload/';
$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())
{
$error = array('error' => $this->upload->display_errors());
$result['success'] = 1;
$result['message'] = $error;
}
else
{
$result['success'] = 0;
$result['message'] = "Successful Upload";
}
die(json_encode($result));
}
但错误出现如下:
Array
如何从数组中获取错误消息?