I've created validation rules for image uploading as follows.
$this->form_validation->set_rules('display_photo', 'Display Photo', 'callback_file_required|callback_file_size_max[1000]');
In controller I've included callback function as follows.
public function file_required($display_photo) {
if($_FILES[$display_photo]['size'] == 0) {
$this->form_validation->set_message('file_required', 'Upload a file.');
return false;
}
return true;
}
public function file_size_max($display_photo, $max_size) {
if($_FILES[$display_photo]['size'] > $max_size) {
$this->form_validation->set_message('file_size_max', 'This file exceeds max size.');
return false;
}
return true;
}
Only first rule is executing but not second rule. Please help me to find out the solution.