Can Image或任何其他文档(pdf / word / text)可以同时上传吗?

时间:2013-10-30 11:34:42

标签: php codeigniter

我正在尝试上传图片&其他文档,如PDF / doc / text等,只有一种形式,但我一次只能上传一件东西,我可以使用codeIgniter上传一个表格吗?

2 个答案:

答案 0 :(得分:0)

您可以使用单个表单,但控制器的逻辑必须不同才能接受多个文件

$this->load->library('upload', $config); //initial load of the upload library
$this->upload->do_upload($field_name1); //uploading first file
[...]
$this->upload->initialize($config); //re-initializing the config
$this->upload->do_upload($field_name2); //uploading second file

如果您要上传更多文件,可能需要将逻辑放在循环中。

答案 1 :(得分:0)

是的...我们可以在codeigniter功能的帮助下同时上传不同的格式。

首先为一种格式初始化一个配置,如:

$config['upload_path'] = $upload_path;
$config['file_name'] = rand(10,99);
$config['allowed_types'] = 'gif|jpg|png';

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

$this->upload->do_upload($filename)

上传一个格式文件,然后重置配置

unset($config);
$this->image_lib->clear();

之后,您可以为另一种格式初始化另一种配置。

相关问题