Welcome Guest, Not a member yet? Register   Sign In
File input array uploads
#1

[eluser]nelson.wells[/eluser]
I can't seem to figure out how to upload multiple files with a file input array using the upload class. Intuitively, I think it should be simple but I haven't been able to get it to work.

Here is the upload form.

Code:
<?php echo form_open_multipart("quote/do_upload"); ?>
<ul>
    <li>&lt;?php echo form_upload("image[]"); ?&gt;</li>
    <li>&lt;?php echo form_upload("image[]"); ?&gt;</li>
    <li>&lt;?php echo form_upload("image[]"); ?&gt;</li>
    <li>&lt;?php echo form_upload("image[]"); ?&gt;</li>
    <li>&lt;?php echo form_upload("image[]"); ?&gt;</li>
    <li>&lt;?php echo form_submit("submit", "Upload images"); ?&gt;</li>
</ul>
&lt;?php echo form_close(); ?&gt;

And here is the controller function to which the view is posted.

Code:
function do_upload()
        {    
            //make sure they are logged in
            if( ! $this->eppauth->is_logged())
            {                
                redirect("user/login");
            }
            
            //load libraries
            $this->load->library("upload");
            
            //config settings for the file upload
            $config['upload_path'] = '../uploads/';
            $config['allowed_types'] = 'gif|jpg|png';
            
            $this->upload->initialize($config);
            
            foreach($_FILES['image'] as $key => $value)
            {
                if( ! $this->upload->do_upload($key))
                {
                    //upload unsuccessful
                }
                else
                {
                    //upload successful
                }
            }
            
            echo $this->upload->display_errors();
        }

It seems pretty straight-forward, but the display_errors function is telling me that I did not upload a file for every input box. I've tried different variations of the field supplied to do_upload, but I can't imagine why it would be something other than image[0] (for the first input box, for example).

I've managed to use the upload class successfully with single image uploads and multiple file uploads with different names (i.e. not an array of file inputs), so I'm fairly sure the probelm is in that.
#2

[eluser]Krzemo[/eluser]
google 'uploadify' or 'swf upload'
#3

[eluser]nelson.wells[/eluser]
I'm aware of those tools and if they're my only options, but is there a reason I can't do this with plain forms?




Theme © iAndrew 2016 - Forum software by © MyBB