嗨,我是 codeigniter 的新手,你能帮我在 codeigniter 中插入多个文件(文档和图像)吗?这是我的示例代码
看法:
<label>Picture</label>
<input type="file" name="userfile" size="100" />
<label>Document</label>
<input type="file" name="documentfile" size="10" />
控制器:
$m = $_FILES['userfile']['name'];
$n = $_FILES['documentfile']['name'];
if ($m !== "")
{
$config['upload_path'] = './upload_images/';
$config['allowed_types'] = 'jpg|png|jpeg|gif';
$config['max_size'] = '0'; // 0 = no file size limit
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['overwrite'] = TRUE;
$this->load->library('upload', $config);
$this->upload->do_upload();
$upload_result = $this->upload->data();
}
elseif ($n !== "")
{
$config_document['upload_path'] = './upload_documents/';
$config_document['allowed_types'] = 'pdf';
$config_document['max_size'] = '0';
$config_document['overwrite'] = TRUE;
$this->load->library('upload', $config_document);
$this->upload->do_upload();
$upload_result2 = $this->upload->data();
}
$image_filename = $upload_result['file_name'];
$docu_filename = $upload_result2['file_name '];
$this->MODEL->add_asset($image_filename, $docu_filename);
我试图回显两个文件名并且它有效,但我的 $docu_filename 生成 NULL 值;请帮忙。谢谢你