Hi guys i am trying to upload image in to uploads folder and insert that path into the database when i tried noting is happening.i don't know what is the exact problem when i upload the image it is showing upload image name in URL. like this
http://localhost/pes/Content/editContent?details=download.jpg&uploadimg=upload
Here is my controller:
function do_upload() {
$config['upload_path'] = '/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '';
$config['max_height'] = '';
$config['overwrite'] = TRUE;
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
if (!$this->upload->do_upload()) {
$error = array('error' => $this->upload->display_errors());
$this->Content_model->insert_images($this->upload->data());
$this->load->view('template/header');
$this->load->view('content/content', $error);
$this->load->view('template/footer');
} else {
$this->Content_model->insert_images($this->upload->data());
$data = array('upload_data' => $this->upload->data());
$this->load->view('template/header');
$this->load->view('content/editdescription', $data);
$this->load->view('template/footer');
}
}
Here is my model:
function insert_images($image_data = array()){
$data = array(
'details' => $image_data['details']
);
$this->db->insert('contentdetails', $data);
}
Here is my view:
<form>
<?php echo form_open_multipart('Content/do_upload'); ?>
<div class="form-group">
<div class="col-sm-9">
<input type="file" name="details" size="20" multiple="true" />
</div>
</div>
<br /><br />
<button type="submit" name="uploadimg" value="upload" class="form-control btn btn-main">Upload File</button>
</form>
Can any one help me what mistake i have done.
Thanks in advance.
$errorvar in your view. what does it say? or echo it in your controller$image_data['details']isn't defined anywhere