文件上传的加密名称不能为空。Codeigniter

时间:2018-11-29 08:20:29

标签: php phpmyadmin codeigniter-3 multifile-uploader

我的代码之前运行正常,我使用的是$config['file_name'],当我将其更改为$config['encrypt_name']时,该列不能为空。 我在视图中有10个输入文件,其中一些未显示取决于组合框的选择。我该如何解决?

控制器:

public function pengajuan()
{
    $username = $this->input->post('username');
    $nama_paket = $this->input->post('nama_paket');
    $pagu_anggaran = $this->input->post('pagu_anggaran');
    $jenis_pekerjaan = $this->input->post('jenis_pekerjaan');
    if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){
  $this->load->library('upload');
  if (!empty($_FILES['surat_permohonan']['name'])){
    $config['upload_path'] = './assets/upload';
    $config['allowed_types'] = 'pdf';
    $config['encrypt_name'] = true;

    $this->upload->initialize($config);

    if ($this->upload->do_upload('surat_permohonan')){
      $data = $this->upload->data();
      $surat_permohonan = $this->upload->data('file_name');
    }
    else{ echo $this->upload->display_errors(); }
  }
    if (!empty($_FILES['dpa']['name'])){
    $config['upload_path'] = './assets/upload';
    $config['allowed_types'] = 'pdf';
    $config['encrypt_name'] = true;

    $this->upload->initialize($config);

    if ($this->upload->do_upload('dpa')){
      $data = $this->upload->data();
      $dpa = $this->upload->data('file_name');
    }
    else{ echo $this->upload->display_errors(); }
        }
        $data=array(
            'username'=>$username,
            'nama_paket'=>$nama_paket,
            'pagu_anggaran'=>$pagu_anggaran,
            'jenis_pekerjaan'=>$jenis_pekerjaan,
            'surat_permohonan'=>$surat_permohonan,
            'dpa'=>$dpa,
            'tanggal'=> date('Y/m/d H:i:s'),
            'status'=> 'tinjau',
        );
    $this->paket_model->tambah_paket($data);
    $this->session->set_flashdata('paket','<div class="alert alert-warning alert-dismissible fade show role="alert"> Pengajuan paket telah dikirim. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>');
    redirect(base_url('paket/form_paket'));
}
else{echo "eror";}
}

型号:

public function tambah_paket($data)
{
    $this->db->insert('tb_paket', $data);
    return TRUE;
}

0 个答案:

没有答案