我試圖將兩個不同字段的兩種不同類型的文件發佈到我的數據庫中。我一直在尋找整個Stack Overvlow的答案,但我仍然無法找到它。使用CodeIgniter上傳多個文件
這是我的控制器:
public function insertLamaran()
{
$pas_foto = ($_FILES['pas_foto']['name']);
$cv = ($_FILES['cv']['name']);
if ($pas_foto !== "")
{
$config['upload_path'] = './uploads/';
$config['log_threshold'] = 1;
$config['allowed_types'] = 'jpg|png|jpeg|gif';
$config['max_size'] = '100000'; // 0 = no file size limit
$config['file_name']='smallImage.jpg';
$config['overwrite'] = false;
$this->load->library('upload', $config);
$this->upload->do_upload('pas_foto');
$upload_data = $this->upload->data();
$data['pas_foto'] = $upload_data['file_name'];
}
if ($cv !== "")
{
$config['file_name']='bigImage.pdf';
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'pdf';
$config['max_size'] = '100000'; // 0 = no file size limit
$config['overwrite'] = false;
$this->load->library('upload', $config);
$this->upload->do_upload('filename1');
$upload_data = $this->upload->data();
$data['cv'] = $upload_data['file_name'];
}
$data['u_id'] = $this->input->post('u_id');
$this->M_upload->insertLamaran($data);
}
,這是我的看法:
<form action="<?php echo base_url('Upload/insertLamaran')?>" method="post">
<input hidden type="text" name="u_id" value="<?php echo ucfirst($this->session->userdata('u_id')); ?>"></input><br>
<div class="row wowload fadeInLeftBig">
<div class="col-sm-6 col-sm-offset-3 col-xs-12">
<label for="pasfoto">Pas Foto (.jpg)</label>
<input id="pas_foto" type="file" name="pas_foto" multiple="true">
<label for="CV">CV (.pdf)</label>
<input id="cv" type="file" name="cv" multiple="true">
<button class="btn btn-primary"><i class="fa fa-paper-plane"></i> Send</button>
</div>
</div>
</form
錯誤說
未定義指數:pas_foto。文件名:controllers/Upload.php行號:22
有沒有人知道發生了什麼,我該如何解決?
謝謝, maaas!但現在,問題是..只有成功上傳的圖像..不是PDF .. –