On the PHP side to miss the resulting file using GD library.
If necessary, reduce the quality of the output file, and passing to generate a preview by sending it back to client (+ confirming receipt by the server).
Keep in mind, will have to increase the available amount of memory for a single PHP process.
In my experience, to GD swallowed a 16 megapixel image, you need 128 MB of RAM.
GD fed before being weighed with also().
If this is not done, and in excess of the limit to pay for processing the library, the script silently stops without telling the client anything, and so you can generate a message that the file is large.