I can't find a good solution to my problem so I need your help.
I have already created the controller, but I think there's something missing, so I can upload my images in a proper way.
Until now I can upload but then if I try to see them in website, I only can see very strange characters and even the name of images in DB is weird.
My controller:
public function do_upload(){
$config['upload_path'] = './assets/img/upload';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 512000;
$config['max_width'] = 2440;
$config['max_height'] = 1600;
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile')) {
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
} else {
$data = array('upload_data' => $this->upload->data());
$this->load->view('perfil');
}
}
and my view:
<?php echo form_open(base_url() . 'index.php/perfil/update/' . $perfil[0]->id_user); ?>
<?php echo form_open_multipart('perfil/do_upload');?>
<input type="file" name="imagem" size="9999" class="form-control" id="imagem">
<label class="texto">Email:</label>
<input type="email" name="email" value="<?php echo $perfil[0]->email; ?>" class="form-control outros">
<label class="texto">Nome:</label>
<input type="text" name="nome" value="<?php echo $perfil[0]->nome; ?>" class="form-control outros">
<label class="texto">Morada:</label>
<input type="text" name="morada" value="<?php echo $perfil[0]->contato; ?>" class="form-control outros">
<label class="texto">Contato:</label>
<input type="text" name="contato" value="<?php echo $perfil[0]->morada; ?>" class="form-control outros">
<label class="texto">Password:</label>
<input type="password" name="password" value="<?php echo $perfil[0]->password; ?>" class="form-control outros">
<br>
<div class="col-md-6 offset-md-3">
<button type="submit" class="btn btn-default btnadmin">Guardar</button><br><br>
my model:
function post($data){
$this->db->insert('utilizadores', $data);
}