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
include('../../../config.php'); $id = strip_tags( $_GET['id'] ); require_once 'Upload.php'; if(isset($_POST['sendFiles'])){ if(isset($_FILES['file']) and ($_FILES['file']['tmp_name'] != "")){ foreach($_FILES['file']['tmp_name'] as $key => $value){ $upload = new Upload($value); if($upload->uploaded){ $upload->file_new_name_body = "sind"; $upload->file_dst_name = strtolower($_FILES); $upload->image_resize = true; $upload->image_ratio_y = true; $upload->image_x = 768; $upload->image_convert = 'jpg'; $upload->jpeg_quality = 80; $upload->process('../imagens/upload/'); if($upload->processed){ $fotos = $upload->file_dst_name; $sql = mysql_query("INSERT INTO fotos_galerias (id_galeria, foto, obs_foto) VALUES ('$id', '$fotos', '$desc_')") or print(mysql_error()); } else { echo $upload->error; } } } } }