Welcome Guest, Not a member yet? Register   Sign In
How do I upload Multiple Files ?
#1

[eluser]sirwan.me[/eluser]
Hi, I want to let users upload 1 image and 1 zip file.

I want to let the image be uploaded to "./uploads/posts" and the zip to "./uploads/files" .. but my below code only allows me to upload 2 images, and not 1 image and 1 zip. When I upload the 2 images, it saves both in ./uploads/posts with both the same name.. except the second file will be the extension twice.. for example..
Quote:post_username_2342342342.jpg.jpg


Below is the controller code:
Code:
//getting the username of the logged in user, to later add the username on the file name
$this->load->model('user_model');
        $userdata = $this->user_model->get_online_user_data($this->session->userdata('username'));
        $username = $userdata['username'];
        


        //Upload PICTURE
        $picture['file_name'] = 'post_'.$username.'_'.now();
        $picture['upload_path'] = './uploads/posts';
        $picture['allowed_types'] = 'png|jpg|gif';
        $picture['max_size'] = '1000000';
        
        $this->load->library('upload', $picture);
        if(!$this->upload->do_upload("picture")){
            echo $this->upload->display_errors();
        }else{
            echo "<h1>Picture Uploaded</h1>";
        }
        
        
        //Upload ZIP
        $config['file_name'] = 'file_'.$username.'_'.now();
        $config['upload_path'] = './uploads/files';
        $config['allowed_types'] = 'zip|rar';
        $config['max_size'] = '1000000';
        
        $this->load->library('upload', $config);
        if(!$this->upload->do_upload("file")){
            echo $this->upload->display_errors();
        }else{
            echo "<h1>ZIP Uploaded</h1>";
        }


Messages In This Thread
How do I upload Multiple Files ? - by El Forum - 06-05-2010, 04:09 PM
How do I upload Multiple Files ? - by El Forum - 06-05-2010, 06:07 PM
How do I upload Multiple Files ? - by El Forum - 06-05-2010, 06:32 PM
How do I upload Multiple Files ? - by El Forum - 06-05-2010, 06:48 PM
How do I upload Multiple Files ? - by El Forum - 06-08-2010, 01:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB