for ($img=0;$img<=5;$img++)
{
if (!empty($_FILES['picture_add_'.$img]))
{
if ($this->upload->do_upload('picture_add_'.$img))
{
$uploaded = $this->upload->data();
$data_picture_add = array(
'filename' => $uploaded['file_name'],
'id' => $last_id
);
$this->db->insert('db_picture_individual', $data_picture_add);
}
}
}
如果我输入2个或更多的文件图片,我只会加密一个文件名。
如何加密所有文件名?
这是观点:
<input name="picture_add_1" class="form-control" style="padding-top: 0;" type="file">
<input name="picture_add_2" class="form-control" style="padding-top: 0;" type="file">
<input name="picture_add_3" class="form-control" style="padding-top: 0;" type="file">
<input name="picture_add_4" class="form-control" style="padding-top: 0;" type="file">
<input name="picture_add_5" class="form-control" style="padding-top: 0;" type="file">
答案 0 :(得分:1)
尝试在循环语句中使用config。
for ($i = 1; $i <= count($_FILES); $i++) {
$config = array();
$config['upload_path'] = './media/project_files';
$config['allowed_types'] = '*';
$config['max_size'] = '51200';
$config['max_width'] = '5000';
$config['max_height'] = '5000';
$config['remove_spaces'] = TRUE;
$config['encrypt_name'] = TRUE;
$ups = $this->upload->do_upload("upload_file$i");
$imgName[$i] = $this->upload->data();
}