Upload file ke direktori masuk, tapi tidak dengan ke database

jadi gini master, sewaktu saya upload file. file yang saya upload masuk ke direktori, tapi ke database nya (file_name) nya engga.

errornya seperti ini Column 'cv_file' cannot be null

INSERT INTO `nilaipegawai` (`nipeg`, `nama`, `grade`, `jabatan`, `unit`, `cv_file`) VALUES ('asdkjh', 'sdkj', 'BAS01', 'Fungsional III', 'sdfkj', NULL)

jadi cv_file nya selalu null

ini controllernya

public function save()
{
$data = array(
'nipeg'=>$this->input->post('nipeg'),
'nama'=>$this->input->post('nama'),
'grade'=>$this->input->post('grade'),
'jabatan'=>$this->input->post('jabatan'),
'unit'=>$this->input->post('unit'),
'cv_file'=>$this->input->post('userfile')
);
// $path = HTTP_UPLOAD_IMPORT_PATH;
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'doc|docx|ppt|pptx|pdf';
$config['max_size'] = 25600;
$config['remove_spaces'] = TRUE;
$this->upload->initialize($config);

$this->load->library('upload', $config);
if ($this->upload->do_upload('userfile')) {
echo "data berhasil terupload";
} else {
$error = $this->upload->display_errors();
print_r($error);
}
$this->load->model('nilai/model_pegawai');	$this->model_pegawai->insertdata($data);
}

ini view nya

<form action="<?php echo site_url('admin/nilai/pegawai/save'); ?>" method="post" enctype="multipart/form-data">
<div class="modal-body">
<div class="form-group">
<label>NIPEG</label>
<input type="text" class="form-control" name="nipeg" placeholder="Masukkan NIPEG Pegawai" required>
</div>
<div class="form-group">
<label>Nama</label>
<input type="text" class="form-control" name="nama" placeholder="Masukkan Nama Pegawai" required>
</div>
<div class="form-group">
<label>Grade</label>
<select class="form-control" name="grade" placeholder="Pilih Grade" required>
<option value="ADV01">ADV01</option>
<option value="ADV02">ADV02</option>
</select>
</div>
<div class="form-group">
<label>Jabatan</label>
<select class="form-control" name="jabatan" placeholder="Pilih Jabatan" required>
<option value="Manajemen Dasar">Manajemen Dasar</option>
<option value="Manajemen Menengah">Manajemen menengah</option>
<option value="Manajemen Atas">Manajemen Atas</option>
</select>
</div>
<div class="form-group">
<label>Unit</label>
<input type="text" class="form-control" name="unit" placeholder="Masukkan Unit Pegawai" required>
</div>
<div class="form-group">
<label>File CV</label>
Pilih File:<input type="file" class="form-control" id="userfile" name="userfile">
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-sign" id="btn-sign" name="button">Simpan</button>
</div>
</form>

terimakasih master mohon bantuannya

avatar nurard1408
@nurard1408

10 Kontribusi 0 Poin

Diperbarui 4 tahun yang lalu

1 Jawaban:

Masukin path file nya ke bagian insert pakai variable

avatar marilynbathory
@marilynbathory

61 Kontribusi 9 Poin

Dipost 4 tahun yang lalu

Login untuk ikut Jawaban