Php 不使用阵列上传codeigniter文件
我使用了codeigniter文件上传,一个和多个都有。但是如果文件名不在数组中,如何上载文件。例如:-如果form1有file1、file2和file3文件输入,并且用户只提供file1和file3。然后,如何识别文件2是否未给出。如果使用数组格式,则无法找到给定的特定字段和未给定的字段Php 不使用阵列上传codeigniter文件,php,arrays,codeigniter,file-upload,Php,Arrays,Codeigniter,File Upload,我使用了codeigniter文件上传,一个和多个都有。但是如果文件名不在数组中,如何上载文件。例如:-如果form1有file1、file2和file3文件输入,并且用户只提供file1和file3。然后,如何识别文件2是否未给出。如果使用数组格式,则无法找到给定的特定字段和未给定的字段 我已经尝试了基于数组的上传,但是,任何缺少的文件都会给我一个错误的索引数组。我需要有一个适当的$\u POST,其中明确给出了未选定的表单成员。它将只发布有价值的$\u文件 HTML <input ty
我已经尝试了基于数组的上传,但是,任何缺少的文件都会给我一个错误的索引数组。我需要有一个适当的
$\u POST
,其中明确给出了未选定的表单成员。它将只发布有价值的$\u文件
HTML
<input type="file" name="mass_consume_upload[]" />
<input type="file" name="mass_consume_upload[]" />
<input type="file" name="mass_consume_upload[]" />
请出示你的密码…这真是一个大罪。当文件未被选中时,我忘记了文件输入中的错误值。谢谢你的解决方案。同时,我想到了另一种解决方案,我在表单之前下载图像,从数据库中获取文件id,并将id放在原始表单中。但你的解决方案更优雅。谢谢,如果我能帮你的话,我很高兴。
$this->load->library('upload');
$tempfiles = $_FILES;
//print_r($tempfiles);
foreach ($tempfiles as $files) {
$_FILES['mass_consume_upload'] = $files;
$this->upload->initialize(array(
'upload_path' => $path,
'allowed_types' => 'pdf',
'overwrite' => FALSE
));
if (!$this->upload->do_upload('mass_consume_upload')) {
$uploadArr['error'][] = array(
'filename' => $_FILES['mass_consume_upload']['name'],
'msg' => $this->upload->display_errors('', '')
);
} else {
$uploadArr['success'][] = array('filename' => $_FILES['mass_consume_upload']['name']);
}
}