Welcome Guest, Not a member yet? Register   Sign In
Uploads, with email confirmation
#4

[eluser]Milos Dakic[/eluser]
Code:
class Upload extends Controller {
  function Upload() {
      parent::Controller();
      $this->load->helper(array(‘email’,‘form’,‘url’));
  }
  
  function index() {  
      $this->load->view(‘upload/upload_form’, array(‘error’ => ’ ’ ));
  }

  function do_upload() {
      $config[‘upload_path’] = ‘./uploads/’;
      $config[‘allowed_types’] = ‘gif|jpg|png’;
      $config[‘max_size’]  = ‘’;
      $config[‘max_width’]  = ‘’;
      $config[‘max_height’]  = ‘’;
      
      $this->load->library(‘upload’, $config);
  
      if ( ! $this->upload->do_upload()) {
        $error = array(‘error’ => $this->upload->display_errors());
        
        $this->load->view(‘upload/upload_form’, $error);
      }  
      else {
        $data = array(‘upload_data’ => $this->upload->data());  
        $this->_send_email();
        $this->load->view(‘upload/upload_success’, $data);

      }
    }
      function _send_email() {
        $this->email->to(‘[email protected]’, ‘Webmaster’);
        $this->email->subject(‘A file has been added’);
      }
}

Also noticed you named the controller the same name as the class as well as your upload method. Maybe try changing them to something else just to see what happens.


Messages In This Thread
Uploads, with email confirmation - by El Forum - 11-18-2009, 06:08 PM
Uploads, with email confirmation - by El Forum - 11-18-2009, 06:56 PM
Uploads, with email confirmation - by El Forum - 11-18-2009, 07:12 PM
Uploads, with email confirmation - by El Forum - 11-18-2009, 07:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB