Better to do something like:

```php
$error=$file->getError();
if($file!==null && $error!=UPLOAD_ERR_OK) {
  if($error==UPLOAD_ERR_NO_FILE)
  ...
}
```