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.
My code is like this, but how to get the $imagem_nome that is the image name saved?
$x = mysql_query("INSERT INTO foto_galeria (id_galeria, foto, comentario) VALUES ('$id_galeria', '$imagem_nome', '$comentario')");
$handle->Process('./fotos_galeria/');
if ($handle->processed) {
// everything was fine !
echo ' file uploaded with success';
echo round(filesize($handle->file_dst_pathname)/256)/4 . 'KB';
echo ' link to the file just uploaded: file_dst_name';
}