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
if ($handle->uploaded){ $handle->allowed = array('image/jpeg','image/gif','image/png'); $handle->file_safe_name = true; $handle->mime_check = true; $handle->mime_magic_check = true; $handle->mime_getimagesize = true; $handle->no_script = true; $handle->file_overwrite = false; $handle->image_resize = true; $handle->image_ratio_y = true; //.......... }