Looking at the example found here in the Codeigniter Users Guide, I’m left wondering what calling if( !$this->upload->do_upload() ) from within the do_upload() method itself does.
Here’s a paste of the code direclty.
class Upload extends CI_Controller {
function __construct() {
parent::__construct();
}
function do_upload() {
$config['upload_path'] = './uploads/';
$this->load->library('upload', $config);
// ** My question starts here **
if ( !$this->upload->do_upload() ) {
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
}
As I see it, it’s checking the do_upload() method from within do_upload() itself .. am I mistaken?
Forgive my naivety, but I’ve never seen this before .. is it a common practice?
What does it do?
is calling the do_upload function which is in CI’s own upload class.
The example in the docs isnt the best.
So it isnt calling do_upload within your controller again, it is calling do_upload in the upload class which does the actual uploading.
HTH