What is the purpose of the Upload Class in CodeIgniter?

The Upload Class in CodeIgniter is used to handle file uploads in web applications. It provides methods for configuring and managing file uploads, including setting upload preferences, validating file types and sizes, and moving uploaded files to a specified destination.

// Example code snippet demonstrating how to use the Upload Class in CodeIgniter

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;

$this->load->library('upload', $config);

if (!$this->upload->do_upload('userfile')) {
    $error = array('error' => $this->upload->display_errors());
    print_r($error);
} else {
    $data = array('upload_data' => $this->upload->data());
    print_r($data);
}