ファイルのアップロード以外のすべてのフィールドの検証を確認する必要があります。そこで検証が成功したら、ファイルを確認します。例:
function someform()
{
// some variables for fields
($this->form_validation->run() == TRUE)
{
$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);
$fileTagName = 'myfile'; // e.g <input type='file' name='myfile' />
if ($this->upload->do_upload($fileTagName))) {
//Success in validation of all fields.
}
else {
//Failed to upload file.
echo $this->upload->display_errors('', '');
}
}
else
{
//Other fields failed.
}
}