function upload() {
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$config['upload_path'] = '/var/www/images';
$config['allowed_type'] = "JPG|PNG";
$config['max_size'] = "256000";
$config['max_width'] = '5000';
$config['max_height'] = '5000';
$this->load->library('upload', $config);
$SelectedFile = 'SelectedFile';
$this->upload->initialize($config);
if ($this->upload->do_upload("SelectedFile")) {
// $error = array('error' => $this->upload->display_errors());
echo json_encode(array('message' => 'fout',
'error_message' => $this->upload->display_errors('', ''),
'post' => $_FILES));
} else {
//$imgdata = array('upload_data' => $this->upload->data());
$imgdata['upload_data'] = $this->upload->data();
echo json_encode(array('message' => 'ok', 'upload_data' => $this->upload->data()));
}