开发者

Upload two files at once

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')) {
开发者_如何学C        $error = array('error' => $this->upload->display_errors());
        return $error;
    } else {


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜