[eluser]Unknown[/eluser]
Hi all, I need help, i'm a newbie in CI.
I know that is inappropriate add a new method directly on a CI lib (in this case Upload).
Whatever, I have a problem.
The thing is i created a method to upload multiple files and works almost fine.
This method i added it to Upload CI class and when i called it from my 'Upload' controller (note: same name than CI Lib) it seems the Upload CI lib load twice!
The METHOD in my Upload CONTROLLER code:
Code:
function multiple_files_form()
{
if($this->phpauthent->is_logged_in())
{
$data['header'] = 'Ajax Upload';
//Upload files with single element
$data['extraHeadContent'] = "[removed] arrayExt = new Array('.pdf', '.jpeg', '.jpg', '.png', '.gif'); [removed]";
$data['extraHeadContent'] .= "[removed][removed]";
//Load Script Module
$data['extraHeadContent'] .= "[removed][removed]";
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'pdf|jpeg|jpg|png|gif';
$config['max_size'] = '100';
$this->load->library('upload', $config);
if(isset($_FILES['files']))
{
if (! $this->upload->do_multiple_upload($_FILES['files']))//If there is some error...
{
$data['errors'] = $this->upload->display_errors();
$this->load->view('upload_files', $data);
}
else
{
if($this->upload->do_multiple_upload($_FILES['files']))//If is a succesfull upload...
{
echo implode(" / ", $this->upload->get_unique_file_names());
$success_data['sucess_message'] = 'Los archivos se han subido satisfactoriamente.';
$this->load->view('success', $success_data);
}
}
}
else//If is the first time opening the form...
{
$data['errors'] = '';
$this->load->view('upload_files', $data);
}
}
else
{
redirect('/auth');
}
}
The method added into CI Upload Lib in the next post....