With a valid visa invitation from an accredited language school, it is possible to apply for a visa extension at the Public Security Bureau in Shanghai. Whether an extension is granted however is decided upon by the visa officer. As anything happening in the Chinese bureaucracy can be a bit unpredictable, we recommend you to decide upon the length of your stay in China before you come to Shanghai and apply for a visa for the full duration at the beginning.