[eluser]cdechery[/eluser]
I'm just finnishing my imagem upload form, it's all working good, all the validations thumbnail creation and such.
And then I stumble into something really weird.
I'm testing for invalid file type, I have this:
Code:
$msg = $this->upload->display_errors() ;
If I echo it, it gives me the string with the error, no problem.
But later in the code I have this:
Code:
echo json_encode( array('status' => $status, 'msg' => $msg) );
and it produces
{"status":"error","msg":null}
WTF? Where does the null come from?
Even If I echo $msg value right before the json call, it shows the string correctly. I tried print_r and var_dump and it displays the string (it is really a string) correctly. Only json sees it as null.
The following code
Code:
echo $msg;
$this->output->set_content_type('application/json')->set_output( json_encode(array('status' => $status, 'msg' => $msg) ));
produces
Quote:O tipo de arquivo que você está tentando enviar não é permitido.
{"status":"error","msg":null}
Any hints?