This is my code, my photo can\'t be inserted into the database.
Actually I want to make an online exam with the codeigniter. I want to upload the question with the p
Kindly use this code
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Dashboard extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->model('soal_model');
}
function insert()
{
$config =array(
'upload_path' => './images',
'allowed_types' => 'gif|jpg|png|jpeg',
'max_size' => '2500',
);
$this->load->library('upload', $config);
$this->upload->do_upload('file_upload');
$upload_data = $this->upload->data();
$file_name = $upload_data['file_name'];
$data = array(
'foto' => $file_name,
);
$hasil = $this->soal_model->Simpan('soal', $data);
if($hasil>=1){
redirect('dashboard/index', $data);
}
}
?>