class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
Thanks for posting this thread. I process thousands of photos a month using this wonderful class, but about 1 in 500 has this same problem: won't process and says corrupted jpeg data. Based on the discussion in this thread, I was able to find a fix that worked for me. Anyone else having the same problem should try it: add this line to your php.ini file:
gd.jpeg_ignore_warning = 1
Mine was set to 0 before I changed it.