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
$this->mime_magic = false;
If it is buggy, you can deactivate mime_content_type by setting mime_magic to false in the init() function: