• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing "userfile" to something else.

#1
[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);
  }

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.