这是我的上传功能
public function do_upload()
{
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('customer_photo'))
{
$responce->success = false;
$responce->data['error'] = $this->upload->display_errors();
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->_do_resize($data);
}
echo json_encode($responce);
}
这是我在firebug控制台上看到的json
{"success":false,"data":{"error":"<p>The filetype you are attempting to upload is not allowed.<\/p>"}}</p>
知道为什么它包含</p>
和这些<\/p>
?
此致
答案 0 :(得分:5)
根据manual,$this->upload->display_errors()
将错误消息包装在<p>
标记中。
您可以传递分隔符的参数,以便将错误包装在您想要的内容中。
$this->upload->display_errors('', '');