CodeIgniter Forums
Changing "userfile" to something else. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Changing "userfile" to something else. (/showthread.php?tid=52137)



Changing "userfile" to something else. - El Forum - 05-30-2012

[eluser]Unknown[/eluser]
So im really new to CI, and im making a test project. So i want to make a small form where u enter some data and choose picture to upload.
Because of the problems with uploading, i only focused on setting form to upload things. I got it to work if i set name of file in form to "userfile", but i read in user guide that there is solution to change that name and use it as
$this->upload->do_upload($filename)
,but i can't manage to do it. So any help?
Here's the code:
Code:
$config['upload_path'] = './uploads/';
  $config['allowed_types'] = 'gif|jpg|png';
  $config['max_size'] = '10000';
  $config['max_width']  = '1024';
  $config['max_height']  = '768';

  $this->load->library('upload', $config);
                $filename=$this->input->post('picture');

  if ( ! $this->upload->do_upload($filename))
  {
                    $data['error']='Error!';
   $this->load->view('sma/header', $data);
                        $this->load->view('sma/upload_form', $data);
                        $this->load->view('sma/footer', $data);
  }
  else
  {
   $data['error'] = 'Success!';

   $this->load->view('sma/header', $data);
                        $this->load->view('sma/upload_form', $data);
                        $this->load->view('sma/footer', $data);
  }



Changing "userfile" to something else. - El Forum - 05-31-2012

[eluser]meer[/eluser]
can u please provide the full controller code........