php - 如何将多个文件名发送到数据库并将文件移动到文件夹?代码点火器
问题描述
我想上传多张图片。但我不知道我将数据发送到数据库以及如何将文件移动到文件夹。这是我的观点:
<div class="form-group">
<div class="custom-file">
<input type="file" class="form-control custom-file-input" name="uploadFile[]" id="uploadFile" multiple>
</div>
</div>
这是我的控制器:
public function add_event() {
// Our calendar data
$judul = $this->input->post('judul', TRUE);
$waktu_mulai = $this->input->post('mulai', TRUE);
$waktu_berakhir = $this->input->post('berakhir', TRUE);
$lokasi = $this->input->post('lokasi', TRUE);
$scope = $this->input->post('scope', TRUE);
$kategori = $this->input->post('kategori', TRUE);
$satuan_kerja = $this->input->post('satuan_kerja', TRUE);
$keterangan = $this->input->post('keterangan', TRUE);
$agenda_pimpinan = $this->input->post('agenda_pimpinan', TRUE);
// var_dump (count($upload_file)); die;
for($i = 0; $i < count($upload_file); $i++) {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'jpg|jpeg|png';
$config['max_size'] = '500';
$this->load->library('upload', $config);
$this->KalenderModel->addEvent(array(
'judul' => $judul,
'mulai' => $waktu_mulai,
'berakhir' => $waktu_berakhir,
'lokasi' => $lokasi,
'scope' => $scope,
'satuan_kerja' => $satuan_kerja,
'keterangan' => $keterangan,
'kategori' => $kategori,
'lampiran' => $uploadfile,
'tampilkan_agenda_pimpinan' => $agenda_pimpinan
));
}
redirect('agendakerja/kalender');
} //end function
有人可以帮忙吗?
解决方案
推荐阅读
- linq - 我怎样才能让 ToLower 在表达式中工作?
- java - 计算笔画数以为二维数组画布着色
- c# - 如何从我的 blazor (c#) 代码中连接到 c# web api,两者都在 gitpod 上运行?
- processing - 我如何制作一个计数器来记录有多少人走过 Kinect 并在它检测处理中的新动作时让骨架改变颜色
- javascript - SAPUI5中的iframe:第一次加载URL更改为父页面后
- javascript - 如何使网页显示特定的数据库项?
- r - 发送“未分类”变量作为函数参数?
- html - 如何在所有生成的 html 文件中自动添加 css 导入?
- c# - 如何关闭客户端连接并返回 NETMQ 中的调用?
- javascript - “无法读取 null 的属性‘innerHTML’”错误