0

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 Answer 1

1

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);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.