Advertisement
yesamarcos

Fazendo upload de imagens no Codeigniter 3

May 24th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. public function do_upload(){
  2.  
  3.     $config['upload_path']          = './uploads/'; // chmod 0777
  4.     $config['allowed_types']        = 'gif|jpg|png';
  5.     $config['max_size']             = 100;
  6.     $config['max_width']            = 1024;
  7.     $config['max_height']           = 768;
  8.  
  9.     $this->load->library('upload');
  10.     $this->upload->initialize($config);
  11.  
  12.     // O name do seu input file deve ser userfile ...
  13.     if ($this->upload->do_upload()){
  14.         // Dados da imagem e mensagem de sucesso ...
  15.         $data = array('upload_data' => $this->upload->data());
  16.         $this->load->view('upload_success', $data);
  17.     }
  18.     else
  19.     {
  20.         // Descreve o erro ao tentar subir a imagem ...
  21.         $error = array('error' => $this->upload->display_errors());
  22.         $this->load->view('upload_form', $error);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement