Controller:
public function generate($id,$type){
$method = $_SERVER['REQUEST_METHOD'];
if($method != 'POST'){
json_output(400,array('status' => 400,'message' => 'Bad request.'));
} else {
$config['upload_path'] = './files/';
$config['allowed_type'] = 'gif|jpg|png';
$config['max_size'] = '2048';
$config['max_width'] = '2024';
$config['max_height'] = '2008';
$this->load->library('upload',$config);
if($this->upload->do_upload('fileImagen')){
json_output($response['status'],$this->upload->display_errors());
} else {
$file_info = $this->upload->data();
$descrption = $this->input->post('description');
$location = $this->input->post('location');
$date = date("Y-m-d");
$time = date("H:i:s", strtotime('+12 hours'));
//$file = $file_info['file_name'];
$text = $this->input->post('titImagen');
$data = array(
'usuario' => $id,
'tipo' => $type,
'fecha' => $date,
'hora' => $time,
'obsUsuario' => $descrption,
'localizacion' => $location,
'foto' => $text
);
$this->load->model('Reportmodel');
$response = $this->Reportmodel->create($data);
}
}
}
Model
public function create($data){
$this->db->trans_start();
$this->db->insert('reporte',$data);
if($this->db->trans_status() == FALSE){
$this->db->trans_rollback();
return array('status' => 500,'message' => 'Internal server error.');
} else {
$this->db->trans_commit();
return array('status' => 200,'message' => 'Registrado correctamente');
}
}
It adds the data perfectly to the database, but the image does not upload it, I am sending the image via POSTMAN, since it is API, does anyone know what is wrong? the folder where the data is saved is in a folder created files
in the codeigniter root.
I was looking at it possibly because of my htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Does anyone know what the error might be?