The process for obtaining a visa to enter China and related residence and other permits can get confusing very fast. The entire process was revamped in 2013 and changes are constantly being made to how policy is regulated.

This comprehensive guide to Chinese visas by China's Global Times is extremely informative and covers a wide variety of situations, and is updated as regulations change. They also have a Q&A section so if your situation isn't covered by the guide, you can still get answers.

Another good guide can be found on the Law and Border blog, written by an American lawyer in Beijing.

A 72-hour transit visa is also available for those that hold a passport from a qualifying country who have a long layover in Shanghai. Bear in mind that you need to have an ongoing/transit ticket to a third location.