一次上传两个文件

时间:2010-05-18 01:26:58

标签: php codeigniter

我正在尝试使用codeigniters上传类一次上传两个文件(两个文件字段)。尽管提供了字段名称codeigniter在第二个字段上产生错误。

我这是codeigniter,php或html的限制,还是我只是简单地使用该类?

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

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

在图像字段上生成:

The filetype you are attempting to upload is not allowed.

以下是我的两个功能

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 {

1 个答案:

答案 0 :(得分:4)

每次上传新文件时,它都会将课程加载为$this->load->library('upload');,然后使用$this->upload->initialize($config);