Welcome Guest, Not a member yet? Register   Sign In
Storing multiple entries to database with do_upload
#1

[eluser]jaybizzle[/eluser]
I'm uploading mutiple files and cant seem to figure out how to store multiple entries of the file_name & file_path to database for all my files that are being uploaded, only the first file data is stored into the db but all my images are uploaded.

If anyone can give me some advice that be great. Thanks!

Code:
$files = $this->upload->do_upload();    
    
    if ( ! $files)
    {
        $data['error'] = array('error' => $this->upload->display_errors());
    }  
    else
    {    
        //$data['error'] = array('error' => $this->upload->display_errors());
        $uploaddata = $this->upload->data();

        $filepath = $uploaddata['full_path'];
        $filename = $uploaddata['file_name'];

        $array = array(
            'image_path' => $filepath,
            'filename' =>$filename,
        );

        $this->db->insert('images', $array);
        
        $data['upload_data'] = array('upload_data' => $uploaddata);
        
    }
#2

[eluser]NateL[/eluser]
What does your form look like that's submitting the multiple uploads?
#3

[eluser]jaybizzle[/eluser]
I'm using jquery.Multi File Upload Plugin

Code:
<form enctype="multipart/form-data">
<p>&lt;input type="file" name="files[]" value="" class="multi" accept="gif|jpg" maxlength="3" /&gt;&lt;/p>
<p id="filelist"></p><p>
&lt;input type="submit" name="" value="Upload"  /&gt;&lt;/p>&lt;/form&gt;




Theme © iAndrew 2016 - Forum software by © MyBB