Upload two files at once

Posted by Keyo on Stack Overflow See other posts from Stack Overflow or by Keyo
Published on 2010-05-18T01:26:58Z Indexed on 2010/05/18 1:30 UTC
Read the original article Hit count: 317

Filed under:
|

I am trying to upload two files at once (two file fields) with codeigniters upload class. Despite having provided the field name codeigniter produces errors on the second field.

I this a limitation of codeigniter, php or html or am I simply using the class incorectly?

$this->upload->do_upload('video_file')

$this->upload->do_upload('image_file')

Produces this on the image field:

The filetype you are attempting to upload is not allowed.

Here are my two functions

function upload_image() {
    $thumb_size = 94;
    $config['upload_path'] = './assets/uploads/images/';
    $config['allowed_types'] = 'jpg|png|gif';
    $config['max_size'] = '2048';
    $config['file_name'] = 'video_' . rand(999999, 999999999);
    $this->load->library('upload', $config);

    if (!$this->upload->do_upload('image_file')) {
        $error = array('error' => $this->upload->display_errors());
        return $error;
    } else {

function upload_video() {


    $config['upload_path'] = './assets/uploads/videos/';
    $config['allowed_types'] = 'flv';
    $config['max_size'] = '0';
    $config['file_name'] = 'video_' . rand(999999, 999999999);
    $this->load->library('upload', $config);
    if (!$this->upload->do_upload('video_file')) {
        $error = array('error' => $this->upload->display_errors());
        return $error;
    } else {

© Stack Overflow or respective owner

Related posts about codeigniter

Related posts about php