views:

34

answers:

1

I’m currently using jQuery’s Multiple image uploader for my form in CI. This works superbly however I would like to insert the file names, etc in to the database - anybody any ideas how I can do this?

My controller

$config['upload_path']   = './uploads/';
$config['allowed_types'] = 'gif|jpg|pdf|doc|bmp|png';
$config['max_size']      = '2024';
$config['max_width']     = '1024';
$config['max_height']    = '768';

$this->load->library('upload', $config);
$this->load->library('Multi_upload');

$files = $this->multi_upload-go_upload();
$data = array('upload_data' => $files); 

My View

<input type="file" name="images[]" size="20" class="multi" id="images" maxlength="5" /> 

Any help that would great, thanks.

+1  A: 

I don't know what $this->multi_upload->go_upload() returns you, but if it returns you an array of the uploaded file you only need to do a foreach and then a sql insert.

foreach($files as $file)
{
    $insert = array(
        'filename' => $file["name"],
        'type' => $file["type"]
    );

    $this->db->insert('table', $insert);
}
Isern Palaus