With CodeIgniter 2.1.4 I'm trying to upload a file using ajax and the File Uploading Class. I have the construct in the Controller as:
public function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
And my upload function in the Controller as:
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));
}
But the errors are coming out as:
Array
How can I get the error message out of the array?