Welcome Guest, Not a member yet? Register   Sign In
duplicated extension with multiple uploads
#1

[eluser]yabune[/eluser]
I noticed if I do multiple uploads (from multiple file upload boxes), the second file upload gets the name of the first one but with duplicated extension.

For example, if I have image1.png and image2.png, they are both uploaded to the server, but the second file gets the filename image1.png.png.

The code I'm using is this:
Code:
$config['upload_path'] = 'assets/anexos/';
        $config['allowed_types'] = 'pdf|doc|xls|zip|gif|jpg|png';
        $this->load->library('upload', $config);

        $num_of_anexos = $this->input->post('num_of_anexos');
        for($i=1; $i < ($num_of_anexos+1); $i++)
        {
            if ( (!empty($_FILES['anexo'.$i]['name'] )) && ($this->upload->do_upload('anexo'.$i)))
            {
                $uploaded_file = $this->upload->data();
                $anexo = 'assets/anexos/'.$uploaded_file['file_name'];
                $anexo_id = $this->input->post('anexo'.$i.'_id');
                $anexo_old = $this->anexos_model->get_filepath($anexo_id);
                if ( (!empty($anexo_old)) && ($anexo_old != $anexo) && (file_exists($anexo_old)) )
                {
                    unlink($anexo_old);
                }

                $this->anexos_model->set('produtos',$prod_id, $anexo_id, $uploaded_file['file_name'], $anexo);
            }
            else
            {
                $error .= $this->upload->display_errors();
            }
        }

Did it happens to someone?
#2

[eluser]danmontgomery[/eluser]
File extension problem with upload
#3

[eluser]yabune[/eluser]
[quote author="noctrum" date="1264123812"]File extension problem with upload[/quote]

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB