Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7755853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:40:07+00:00 2026-06-01T12:40:07+00:00

I am trying to upload multiple images and I have a jquery plugin set

  • 0

I am trying to upload multiple images and I have a jquery plugin set up so I can browse for multiple files and select them.

The only problem I am having is accessing the file array in my controller, does anyone know how I can do this? Thanks.

view:

<input type="file" name="userfile[]" id="userfile" class="multi" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:40:08+00:00Added an answer on June 1, 2026 at 12:40 pm

    I had this same issue on a project last year, after a bit of searching I found a perfect function.

    I take no credit it for it, but cannot remmeber where I found it so if anyone knows please link back to the author.

    Make sure the form has the files named like this

    <input type="file" name="userfile"/>
    <input type="file" name="userfile2" />
    <input type="file" name="userfile3" /> ..etc
    

    Or

     <input type="file" name="userfile[]" />
    

    The function..

    function multiple_upload($upload_dir = 'uploads', $config = array())
    {
        $files = array();
    
        if(empty($config))
        {
            $config['upload_path'] = '../path/to/file';
            $config['allowed_types'] = 'gif|jpg|jpeg|jpe|png';
            $config['max_size']      = '800000000';
        }
    
            $this->load->library('upload', $config);
    
            $errors = FALSE;
    
            foreach($_FILES as $key => $value)
            {            
                if( ! empty($value['name']))
                {
                    if( ! $this->upload->do_upload($key))
                    {                                           
                        $data['upload_message'] = $this->upload->display_errors(ERR_OPEN, ERR_CLOSE); // ERR_OPEN and ERR_CLOSE are error delimiters defined in a config file
                        $this->load->vars($data);
    
                        $errors = TRUE;
                    }
                    else
                    {
                        // Build a file array from all uploaded files
                        $files[] = $this->upload->data();
                    }
                }
            }
    
            // There was errors, we have to delete the uploaded files
            if($errors)
            {                    
                foreach($files as $key => $file)
                {
                    @unlink($file['full_path']);    
                }                    
            }
            elseif(empty($files) AND empty($data['upload_message']))
            {
                $this->lang->load('upload');
                $data['upload_message'] = ERR_OPEN.$this->lang->line('upload_no_file_selected').ERR_CLOSE;
                $this->load->vars($data);
            }
            else
            {
                return $files;
            }
        } 
    

    Now it’s been a while since I’ve used it so if you need any extra help setting it up just let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to upload multiple files via a form, but I can only upload
I am trying to write a PHP script that can upload multiple files. for($i=0;$i<count($_FILES['uploadimg']['name']);$i++){
I am trying to upload multiple files but when i select more than 1
I'm trying to upload files for an article model. Since an object can have
I am using Codeigniter and I am trying to upload multiple files into a
I'm building an app where each user can have multiple profiles. Users can upload
The following code uploads multiple images no problem. However, I'm trying to get it
I am trying to use the multiple upload attribute of HTML5 to upload files.
I am trying to upload multiple images using meioupload which works fine if I
i'm trying to allow user to upload multiple images but when i validate the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.