[eluser]xwero[/eluser]
webdezzo you make a common mistake by validating the file in the true branch of the validation->run method. If you do this most of the times you have to copy code from the false branch which fattens your controller.
The correct way to check if a file is added by the user is to check for the upload error 4, see php documentation for more info. The $_FILES global is always an array and by only checking if the filename is present you disregard the possibility of other errors.
So these two things make the code something like this
Code:
if( ! $this->validation->run() || $_FILES['userfile']['error'] == 4)
{
if($_FILES['userfile']['error'] == 4)
{
// add to error_string
}
}
The one problem i have with this method is that the file error appears last but it's possible the file field is at the top of the form but because of the handling of the error_string in the validation library there is no other option.