Welcome Guest, Not a member yet? Register   Sign In
Upload multiple files - duplicated names
#1

[eluser]Mauricio de Abreu Antunes[/eluser]
Well, i need some help to upload multiple files.
If i have a form with 3 inputs
Code:
<input name="userfile[]">
(watch for the brackets - array of files).
How to upload multiple files with a loop through my $_FILES['userfile']?

My code:
I have my configs.
Code:
$config['upload_path'] = './assets/img/upload/'; etc...

And my load
Code:
$this->load->libraty('upload')

My foreach
Code:
foreach($_FILES as $key => $value)
        {
            if( ! empty($key['name']))
            {
                $this->upload->initialize($config);
                if ( !$this->upload->do_upload($key))
                {
                    $data['error'][$j] =  $this->upload->display_errors();    
                    $j++;
                }    
                else
                {
                    $data['upload_data'][$i]  = $this->upload->data();
                    $i++;
                }
            }
        }

How can i verify non duplicate name images?
C:\uploads\image1.jpg
C:\uploads\image2.jpg

Next upload:
C:\uploads\image1.jpg (overwriting C:\uploads\image1.jpg above).

Thanks!

Obs.: when i call initalize and i pass $config['file_name'] = md5(time()) . $key['name'], does it prevent any duplication?
#2

[eluser]Mauricio de Abreu Antunes[/eluser]
Do i need to use that My_Upload lib found here?
Lemme know, please!




Theme © iAndrew 2016 - Forum software by © MyBB