How do expats work legally in Shanghai?

Article 41 under Exit and Entry Administration Law of the People's Republic of China: Foreigners who work in China shall obtain work permits and work-type residence permits in accordance with relevant regulations. No entities or individuals shall employ foreigners who have no work permits or work-type residence permits.