views:

93

answers:

1

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 {
+2  A: 

It worked loading the class as $this->load->library('upload'); then using $this->upload->initialize($config); each time I upload a new file.

Keyo