Welcome Guest, Not a member yet? Register   Sign In
Really Confused about Multiupload Files
#1

[eluser]Unknown[/eluser]
Hi there , Well I'm trying to upload many files using HTML5's
Code:
Multiple="multiple"
in my form :
Here it is my input
Code:
<input type="hidden" name="max_file_size" value="1000000" />
    <input name="files[]" type="file" multiple="multiple"/>
    '.form_error('files[]').'
Now in my controller (where I'm Treating these inputs) i'm doing this :
Code:
public function AddNew()
    {
$this->load->view('admin/news/news');
$this->load ->library('form_validation');
$this->form_validation->set_rules('news_title', '"News\'s Name"','trim|required|min_length[3]|max_length[25]|alpha_dash');
$this->form_validation->set_rules('news_num', '"Manga\'s Type"','trim|required|numeric');
// $this->form_validation->set_rules('files[]', '"Manga\'s files"','required');
if($this->form_validation->run())
{
$title=$this->input->post('news_title');
$num=$this->input->post('news_num');
// if(!file_exists('./assets/mangas/'.$title))
// mkdir('./assets/mangas/'.$title);
mkdir('./assets/mangas/'.$title.'/'.$num);
chmod('./assets/mangas/'.$title.'/'.$num, 0777);
var_dump($_FILES['files']['error']);
foreach($_FILES['files']['name'] as $file){
$config['upload_path'] = './assets/mangas/'.$title.'/'.$num.'';
$config['allowed_types'] = 'gif|JPEG|JPG|png';
$config['max_size'] = '2048';
$this->load->library('upload');
$this->upload->initialize($config);
}

if($this->news->addnew($title,$num) && $this->upload->do_upload('files[]'))
$this->load->view('admin/setpost');

}
else
{
echo $this->upload->display_errors();
$manga['select']=$this->add->Selectall('id >',0);
$this->load->view('admin/news/addnews',$manga);
}
}

As you can see i'm dumping the Errors of upload and each time i have this result in dumping
Code:
array(1) { [0]=> int(0) } // for one file but same thing for many files
and this Sad
Code:
You did not select a file to upload.
This is turning me crazy !!!




Theme © iAndrew 2016 - Forum software by © MyBB