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
$handle = new upload($_FILES['image_field']); if ($handle->uploaded) { if ($handle->file_is_image) { // file is an image $handle->image_resize = true; $handle->image_x = 200; $handle->process('Test'); if ($handle->processed) { echo 'file uploaded'; $handle->clean(); } else { echo 'error : ' . $handle->error; } } else { // file is not an image $handle->clean(); } }