I am working on image upload in CodeIgniter. In this regard I am using following code.
$config['upload_path'] = './files/';
$config['allowed_types'] = 'gif|jpg|png|doc|txt';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile'))
{
$error = $this->upload->display_errors();
echo json_encode(array('success'=>false,'message'=>$error)); //this line is not working.
}
else
{
echo json_encode(array('success'=>true,'message'=>lang('items_successful_updating').' '. $item_data['name'],'item_id'=>$item_id));
}
If I use below code then it is working.
echo json_encode(array('success'=>false,'message'=>'abcdef'));
Why it is happening so?