0 and strlen($_POST["title"][$i]) > 0) { $imageinfo = getimagesize($_FILES['img']['tmp_name'][$i]); $ex_foto = explode(".", $_FILES['img']['name'][$i]); $format = strtolower(end($ex_foto)); if ($_FILES["img"]["size"][$i] <= (50*(1024*1024)) and preg_match("/^[image\/jpeg|image\/png|image\/gif]+$/", $imageinfo["mime"])) { $last_foto1 = mysql_query("SELECT id FROM foto ORDER BY id DESC LIMIT 0,1", $db); $last_foto = mysql_fetch_array($last_foto1); $last_foto = $last_foto["id"] + 1; $upload_path = "../../foto/".$last_foto.".".$format; $upload_path_p = "../../foto/".$last_foto."_p.".$format; $upload_path_m = "../../foto/".$last_foto."_m.".$format; if (move_uploaded_file($_FILES['img']['tmp_name'][$i], $upload_path)) { mysql_query("INSERT ... ",$db); preview($upload_path, $upload_path_p, 150, 150); preview($upload_path, $upload_path_m, 620, 375); $num ++; } } } } ?>