A fire broke out inside a 16-story Upper West Side apartment building early Thursday, injuring seven tenants and five firefighters, the FDNY said.