Codeigniter多上传功能

时间:2017-05-15 00:06:25

标签: codeigniter multi-upload

我已经花了2个小时,但我无法做到。 我有一个表格,其中有3个输入(多个文件)。 我有upload_id1,upload_id2和upload_id3 当我在id1上传时,它也会上传到id1,id2和id3上。

for ($i = 0; $i < count($_FILES['galphoto']['name']); $i++) :

    $data = $this->upload->get_multi_upload_data($galp);

    if (!empty($data)) 
    {
        $many_image = $data[$i]['file_name']; 
        $dataphoto = array
        (
            'photo' => $many_image,
            'tours_id' => $id,
        ); 
        $this->db->insert('gallery_tours', $dataphoto);
    }
endfor;

$galp2 = 'galphoto2';
$this->upload->do_multi_upload($galp2);

for ($i = 0; $i < count($_FILES['galphoto2']['name']); $i++) :

    $data = $this->upload->get_multi_upload_data($galp2);

    if (!empty($data)) 
    {
        $many_image = $data[$i]['file_name']; 
        $dataphoto = array
        (
            'photo' => $many_image,
            'tours_id' => $id,
        ); 
        $this->db->insert('gallery_hotels', $dataphoto);
    }
endfor;

$galp3 = 'galphoto3';
$this->upload->do_multi_upload($galp3);

for ($i = 0; $i < count($_FILES['galphoto3']['name']); $i++) :

$data = $this->upload->get_multi_upload_data($galp3);

    if (!empty($data)) 
    {
        $many_image = $data[$i]['file_name']; 
        $dataphoto = array(
            'photo' => $many_image,
            'tours_id' => $id,
        );
        $this->db->insert('gallery_hostels', $dataphoto);
    }
endfor;

1 个答案:

答案 0 :(得分:0)

尝试在根目录下的index.php中将ENVIRONMENT设置为development,以显示错误。确保您的图像保存路径是可写的。

据我所知,do_multi_upload不是codeigniter上传库中的内置方法。

但是如果您使用此library,请阅读相应的文档,已经提供,并在您的问题中提及并更新您的代码。