public static function getFileSafe(
        string $uploadField,
        Request $request
    ) {
        if (!$request) {
            return null;
        }

        $uploadedFile = $request->file($uploadField);

        //check type because request file method, may returns UploadedFile, array or null
        if (!is_a($uploadedFile, UploadedFile::class)) {
            return null;
        }

        return $uploadedFile;
    }
public static function getFileSafe(
        string $uploadField,
        Request $request
    ) {
        if (!$request) {
            return null;
        }

        $uploadedFile = $request->file($uploadField);

        //check type because request file method, may returns UploadedFile, array or null
        if (!is_a($uploadedFile, UploadedFile::class)) {
            return null;
        }

        return $uploadedFile;
    }
public static function getFileSafe ( string $ uploadField , Request $ request ) { if ( ! $ request ) { return null ; } $ uploadedFile = $ request -> file ( $ uploadField ) ; //check type because request file method, may returns UploadedFile, array or null if ( ! is_a ( $ uploadedFile , UploadedFile :: class ) ) { return null ; } return $ uploadedFile ; }
Return File in passed request if ok, otherwise return null
@param string $uploadField
@param Request $request
@return null|UploadedFile
Return File in passed request if ok otherwise return null