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.
more info about the class
ini_set ( "memory_limit", "20M")
php_value memory_limit 20M
For the memory, PHP is probably running out of memory.
See this thread
Try to raise your local memory to 20M, 32M or more.
You can add this in your script:
Or in a .htaccess file: