Postingan lainnya
Upload gagal di codeigniter
jadi gini master,setiap kali browse data nama file sudah ke index ke database tapi kok selalu gagal terus ke upload yah (file Ga masuk ke direktori)
ini controller
public function save()
{
$path = ROOT_UPLOAD_IMPORT_PATH; //C:/xampp2/htdocs/nilai/uploads/
$config['upload_path'] = $path;
$config['allowed_types'] = 'doc|docx|ppt|pptx|pdf';
$config['remove_spaces'] = TRUE;
$this->upload->initialize($config);
$this->load->library('upload', $config);
if (!$this->upload->do_upload('cv_file')) {
$error = $this->upload->display_errors();
print_r($error);
} else {
$result = $this->upload->data();
echo "";
print_r($result);
echo "</pre>";
}
redirect(site_url('admin/nilai/pegawai'));
}
ini view nya
<form action="<?php echo site_url('admin/nilai/pegawai/save'); ?>" method="post">
<div class="modal-body">
<div class="form-group">
<label>CV</label>
<input type="file" class="form-control" id="userfile" name="cv_file" required>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-sign" id="btn-sign" name="importfile">Simpan</button>
</div>
</form>
terimakasih master, mohon bimbingannya. pclapclapclapclpa
1 Jawaban:
Jawaban Terpilih
Jika mau upload file, saya biasanya di bagian viewnya, stelah atribut method, ada 1 atribut lagi yaitu enctype, jadi kurang lebih seperti ini
<pre> <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>CV</label> <input type="file" class="form-control" id="userfile" name="cv_file" required> </div> </div> <div class="modal-footer"> <button type="submit" class="btn btn-sign" id="btn-sign" name="importfile">Simpan</button> </div> </form> </pre>
#cmiiw