Many apartment residents had to climb down the scaffolding to escape.
One man said he and his wife were napping in their 23rd floor apartment when they smelled smoke. He said he climbed down the scaffolding four stories before being rescued.
It took firefighters more than six hours to put out the flames.
The government said rescuers continued to search inside the charred building, without saying if anyone was unaccounted for.
Earlier reports put the toll at least eight dead and more than 90 injured. The death toll had risen by Monday night to 42, according to the Shanghai government.
One doctor at Shanghai's Jing'an Central Hospital said more than 20 people were admitted for serious injuries.
The official Xinhua news agency said more than 100 residents had been rescued from the apartments that house 156 families.
The Associated Press Contributed to this report.