我不能上传多个文件上传在codeignitor [英] I cant upload Multiple file upload in codeignitor
本文介绍了我不能上传多个文件上传在codeignitor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的观点(html)内容
This is my view (html) content
<tr>
<td width="341" class="linkssubhead">
Subcategory Image <span class="errormsg">*</span>
</td>
<td width="965" align="left">
<input type="file" name="subcategory_image" value="" class="required" /> <span class="errormsg"><?php echo $file_error ; ?> </span>
</td>
</tr>
<tr>
<td width="341" class="linkssubhead">
Subcategory Banner Image <span class="errormsg">*</span>
</td>
<td width="965" align="left">
<input type="file" name="subcategory_banner_image" value="" class="required" /> <span class="errormsg"><?php echo $file_error ; ?> </span>
</td>
</tr>
<tr>
<td width="341" class="linkssubhead">
Subcategory Banner Logo <span class="errormsg">*</span>
</td>
<td width="965" align="left">
<input type="file" name="subcategory_banner_logo" value="" class="required" /> <span class="errormsg"><?php echo $file_error ; ?> </span>
</td>
</tr>
这是我的控制器
$config_image['allowed_types'] = 'gif|jpg|png';
$config_image['overwrite'] =TRUE;
$config_image['subcategory_image']['upload_path'] = './public/subcategory/';
$config_image['subcategory_banner_image']['upload_path'] = './public/subcategory/bannerimage/';
$config_image['subcategory_banner_logo']['upload_path'] = './public/subcategory/bannerlogo/';
$config_image['subcategory_image']['file_name'] = $this->input->post('subcategory_name');
$config_image['subcategory_banner_image']['file_name'] = 'banner_image_'.$this->input->post('subcategory_name');
$config_image['subcategory_banner_logo']['file_name'] = 'banner_logo_'.$this->input->post('subcategory_name');
$this->load->library('upload', $config_image);
$this->upload->initialize($config_image);
if (!$this->upload->do_upload(array('subcategory_image','subcategory_banner_image','subcategory_banner_logo')))
{
$errors = $this->upload->display_errors();
if ($errors)
{
$data['file_error'] = $errors;
$data['body'] = $this->load->view('matress_model/add_subcategory',$data,TRUE);
$this->load->view('page',$data);
}
}
else
{
redirect('fileupload/sucess');
}
提交表单后发生错误
Severity: Warning
Message: Illegal offset type in isset or empty
Filename: libraries/Upload.php
Line Number: 140
如何摆脱这个问题,如何允许多个文件上传?
How do I get rid of this and how can I allow multiple files upload?
推荐答案
为每个图像分别配置一个配置数组,然后上传。像下面这样
Have a separate config array for each image and then upload. like below
//I have given an exmaple for one image repeat this for others,
$config_image[0]['allowed_types'] = 'gif|jpg|png';
$config_image[0]['overwrite'] =TRUE;
$config_image[0]['subcategory_image']['upload_path'] = './public/subcategory/';
$config_image[0]['subcategory_image']['file_name'] = $this->input->post('subcategory_name');
//Load and initialize the library as below and then upload
$this->load->library('upload', $config_image[0]);
$this->upload->initialize($config_image[0]);
这篇关于我不能上传多个文件上传在codeignitor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文