I have an upload form that has ckeditor, before I added the ckeditor to my website it was working, but now that I added the ckeditor nothing gets uploaded to the database. I don't understand why that is happening.
This is my controller
class Bras extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->helper('form');
$this->load->helper('url');
}
function bra_create(){
$this->load->model('admin_model');
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = 'Create a bra item';
/*
$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('content', 'content', 'required');
if ($this->form_validation->run() === FALSE)
{
//$this->load->view('templates/header', $data);
$this->load->view('admin/bra_create');
//$this->load->view('templates/footer');
}
else
{
$this->admin_model->set_bras();
$this->load->view('admin/success');
}*/
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('admin/bras/bra_create', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$upload_info = $this->upload->data();
$slug = url_title($this->input->post('title'), 'dash', TRUE);
$insert_data = array(
'bra_id' => $this->input->post('bra_id'),
'title' => $this->input->post('title'),
'slug' => $slug,
'image_path' => $upload_info['file_path'],
'filename' => $upload_info['file_name'],
'content' => $this->input->post('content'),
'price' => $this->input->post('price')
);
$this->db->insert('bras', $insert_data);
$this->load->view('admin/success', $data);
}
}
This is my view
<html>
<head>
<script src="../ckeditor/ckeditor.js"></script>
<title>Upload Form</title>
</head>
<h2>Create a news item</h2>
<?php echo validation_errors(); ?>
<body>
<?php echo form_open_multipart('admin/bra_create');?>
Title: <br /><input type="text" name="title" /><br />
<input type="file" name="userfile" size="20" /><br />
Content: <br /><textarea class="ckeditor" name="content"></textarea><br />
Price: <br /><input type="text" name="price" /><br />
<input type="submit" value="Submit" /><br />
</form>
<?php echo anchor('admin/bra_view', 'view'); ?>
</body>
</html>