Daftar dan Belajar Sekarang!

Upload gagal di codeigniter

foto nurard1408
6 Kontribusi 0 Coto
6 hari yang lalu
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 "<pre>";
			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

Jawaban
foto Ahmad554
41 Kontribusi 10 Coto
3 hari yang lalu
Jika mau upload file, saya biasanya di bagian viewnya, stelah atribut method, ada 1 atribut lagi yaitu enctype, jadi kurang lebih seperti ini
<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>
#cmiiw


Login untuk diksusi di forum sekolah koding