little stuck with my code
controller
class Upload extends CI_Controller
{
function create()
{
$this->load->view('uploads','upload_doc');
}
function proses()
{
$config['upload_path'] ='./uploads/';
$config['allowed_types'] ='doc|pdf|csv|jpg|jpeg|xlsx|xps';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$config['encrypt_name'] = TRUE;
$this->load->library('uploads' , $config);
if ( ! $this->uploads->do_upload('berkas')){
$error = array('error' => $this->uploads->display_errors());
$this->load->view('uploads','upload_doc', $error);
}
else
{
$data['no_surat'] = $this->upload->data("file_name");
$data['tujuan'] = $this->input->post('tujuan');
$data['keterangan'] = $this->input->post('keterangan');
$data['tipe_berkas'] = $this->upload->data('file_ext');
$data['ukuran'] = $this->upload->data('file_size');
$this->db->insert('ci_barang', $data);
redirect('uploads');
}
}
public function index()
{
$data['Upload'] = $this->db->get(uploads);
$this->load->view('tampil_doc' , $data);
}
function download($id){
$data = $this->db->get_where('upload',['no_surat'=>$id])->row();
force_download('uploads/'.$data->nama_file,NULL);
}
}
and this my view =
<body>
<h3><center>Semua Dokumen</center></h3>
<hr/>
<a href="<?php echo base_url(); ?>index.php/uploads/upload_doc">Tambah Dokumen</a>
<hr/>
<table border="1" width="76%" style="text-align: center;">
<tr>
<th>No</th>
<th>No Surat</th>
<th>Tujuan</th>
<th>Keterangan</th>
<th>Aksi</th>
</tr>
<?php
$no = 1;
foreach ($uploads->result() as $row) {
?>
<tr>
<td><?php echo $no++; ?></td>
<td><img width="100" src="<?php echo base_url(); ?>uploads/<?php echo $row->nama_surat; ?>"/></td>
<td><?php echo $row->tujuan; ?></td>
<td><?php echo $row->keterangan; ?></td>
<td><a href="<?php echo base_url(); ?>index.php/upload/download/<?php echo $row->no_surat; ?>">Download</a></td>
</tr>
<?php
}
?>
</table>
and when i run get error this (why i solved this)
A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant uploads - assumed 'uploads'
Filename: controllers/Upload.php
Line Number: 42
Backtrace:
File: C:\xampp\htdocs\barang-master\application\controllers\Upload.php Line: 42 Function: _error_handler
File: C:\xampp\htdocs\barang-master\index.php Line: 315 Function: require_once