codeigniter上传多个pdf文件错误

问题描述 投票:0回答:1

我有一个带有脚本的简单页面,用于发布要上传到网络服务器上的多个文件。

?php echo form_open_multipart('upload/do_upload');?>

<input type="file" name="userfile[]" size="20" />

<br /><br />

<input type="submit" value="upload" />
</form>

但是我正在尝试很多解决方案来更改仅当我发布1个文件时有效的代码

public function do_upload()
    {
            $config['upload_path']          = './uploads/';
            $config['allowed_types']        = 'gif|jpg|png|pdf';
            $config['max_size']             = 100;
            $config['max_width']            = 1024;
            $config['max_height']           = 768;

            $this->load->library('upload', $config);

            if ( ! $this->upload->do_upload('userfile'))
            {
                    echo "error";
            }
            else
            {
                    echo "upload success";
            }
}

谁能帮我吗?非常感谢

php codeigniter file-upload upload codeigniter-3
1个回答
0
投票

我通常将其用于多部分表格

<?= form_open_multipart('upload/do_upload');?>
<input type="file" name="userfile" id="userfile"/>

我认为您的问题在这里

name=userfile[]

为什么使用数组?您要输入多个文件吗?

© www.soinside.com 2019 - 2024. All rights reserved.