The upper critical field of layered superconductors