@dedrick
To upload images using CodeIgniter, you can follow these steps:
1 2 3 4 |
<form action="upload_image" method="post" enctype="multipart/form-data">
<input type="file" name="image">
<input type="submit" value="Upload">
</form>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
public function upload_image() {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'jpg|png|jpeg|gif';
$config['max_size'] = 10240;
$this->load->library('upload', $config);
if (!$this->upload->do_upload('image')) {
$error = array('error' => $this->upload->display_errors());
print_r($error);
} else {
$data = array('upload_data' => $this->upload->data());
print_r($data);
}
}
|
That's it! You have successfully implemented image upload functionality using CodeIgniter.