Есть форма которая отправляет данные в базу данных и фотографии на сервер в папку IMAGES.
Количество фотографий меняется от 1 до 5-и.
При отправки PHP не проверяет файл на размер и на тип.
Ранее когда этаже форма отправляла одну фотку все работала.
Кусок кода
<?
if (isset($submit2))
{
if (isset($saa)) {trim($saa); }
else {$saa = "";}
if (isset($tel)) {trim($tel); }
else {$tel = "";}
if (isset($mail)) {trim($mail); }
else {$mail = "";}
if (isset($type2)) {trim($type2); }
else {$type2 = "";}
if (isset($rooms2)) {trim($rooms2); }
else {$rooms2 = "";}
if (isset($floor2)) {trim($floor2); }
else {$floor2 = "";}
if (isset($floor22)) {trim($floor22); }
else {$floor22 = "";}
if (isset($remont2)) {trim($remont2); }
else {$remont2 = "";}
if (isset($kv)) {trim($kv); }
else {$kv = "";}
if (isset($olchu)) {trim($olchu); }
else {$olchu = "";}
if (isset($meqsed)) {trim($meqsed); }
else {$meqsed = "";}
if (isset($price2)) {trim($price2); }
else {$price2 = "";}
if (isset($address)) {trim($address); }
else {$address = "";}
if (isset($kupcha)) {trim($kupcha); }
else {$kupcha = "";}
if (isset($meqsed)) {trim($meqsed); }
else {$meqsed = "";}
if (isset($rayon2)) {trim($rayon2); }
else {$rayon2 = "";}
if (isset($rayon22)) {trim($rayon22); }
else {$rayon22 = "";}
if (isset($qesebe)) {trim($qesebe); }
else {$qesebe = "";}
if (isset($foto)) {trim($foto); }
else {$foto = "";}
if (isset($foto2)) {trim($foto2); }
else {$foto2 = "";}
if (isset($hide)) {trim($hide); }
else {$hide = "";}
if (isset($text)) {trim($text); }
else {$text = "";}
if ($nov !== "Torpaq") {
if (empty ($type2)OR empty ($floor2) OR empty ($floor22) OR empty ($rooms2) OR empty ($remont2) OR empty ($saa) OR empty ($nov) OR empty ($price2) OR empty ($rayon22) OR empty ($tel) OR empty ($kv) OR empty ($meqsed) OR empty ($address) OR empty ($qesebe) OR empty ($hide) OR empty ($text))
{
echo "<p style='font-family:Arial, Helvetica, sans-serif; color:#F00; font-size:16px; font-weight:bold; '>Please fill all!</p>";
}
else
{
if ($_FILES['foto']['size'] <= 524288 or $_FILES['foto2']['size'] <= 524288 or $_FILES['foto3']['size'] <= 524288 or $_FILES['foto4']['size'] <= 524288 or $_FILES['foto5']['size'] <= 524288)
{
//$location = "ok.php";
//$sendto = '<META HTTP-EQUIV="Refresh" Content="0; URL='.$location.'">';
$allowed = array('image/jpeg', 'image/jpg', 'image/gif', 'image/png', 'image/pjpeg', 'images/x-png', '');
if (isset($_FILES['foto']) && in_array($_FILES['foto']['type'], $allowed) or isset($_FILES['foto2']) && in_array($_FILES['foto2']['type'], $allowed) or isset($_FILES['foto3']) && in_array($_FILES['foto3']['type'], $allowed) or isset($_FILES['foto4']) && in_array($_FILES['foto4']['type'], $allowed) or isset($_FILES['foto5']) && in_array($_FILES['foto5']['type'], $allowed)) {
if (file_exists($_FILES['foto']['tmp_name']) && is_file($_FILES['foto']['tmp_name']) && in_array($_FILES['foto']['type'], $allowed) or file_exists($_FILES['foto2']['tmp_name']) && is_file($_FILES['foto2']['tmp_name']) && in_array($_FILES['foto2']['type'], $allowed) or file_exists($_FILES['foto3']['tmp_name']) && is_file($_FILES['foto3']['tmp_name']) && in_array($_FILES['foto3']['type'], $allowed) or file_exists($_FILES['foto4']['tmp_name']) && is_file($_FILES['foto4']['tmp_name']) && in_array($_FILES['foto4']['type'], $allowed) or file_exists($_FILES['foto5']['tmp_name']) && is_file($_FILES['foto5']['tmp_name']) && in_array($_FILES['foto5']['type'], $allowed))
{
if ( strlen( $_FILES['foto']['name'] ) > 150 or strlen( $_FILES['foto2']['name'] ) > 150 or strlen( $_FILES['foto3']['name'] ) > 150 or strlen( $_FILES['foto4']['name'] ) > 150 or strlen( $_FILES['foto5']['name'] ) > 150)
{$sendto = "Files name so long";}
else //Şəklin
{ $ndate = date ('Ymdhis');
$foto="img"."$ndate"."{$_FILES['foto']['name']}";
if (empty ($_FILES['foto']['name'])) {$foto="nophoto.jpg";}
move_uploaded_file($_FILES['foto']['tmp_name'], "images/$foto");
$foto2="img2"."$ndate"."{$_FILES['foto2']['name']}";
if (empty ($_FILES['foto2']['name'])) {$foto2="";}
move_uploaded_file($_FILES['foto2']['tmp_name'], "images/$foto2");
$foto3="img3"."$ndate"."{$_FILES['foto3']['name']}";
if (empty ($_FILES['foto3']['name'])) {$foto3="";}
move_uploaded_file($_FILES['foto3']['tmp_name'], "images/$foto3");
$foto4="img4"."$ndate"."{$_FILES['foto4']['name']}";
if (empty ($_FILES['foto4']['name'])) {$foto4="";}
move_uploaded_file($_FILES['foto4']['tmp_name'], "images/$foto4");
$foto5="img5"."$ndate"."{$_FILES['foto5']['name']}";
if (empty ($_FILES['foto5']['name'])) {$foto5="";}
move_uploaded_file($_FILES['foto5']['tmp_name'], "images/$foto5");
}
}
if (empty($foto)) {$foto='nophoto.jpg';}
$result3 = mysql_query ("INSERT INTO data (nov,saa,type2,address,tel,mail,price2,text,rayon2,floor2,floor22,rooms2,remont2,kv,olchu,meqsed,qese be,hide,foto,foto2,foto3,foto4,foto5) VALUES ('$nov','$saa', '$type2','$address','$tel','$mail','$price2','$text','$rayon2','$floor2','$floor22','$rooms2','$remont2','$kv','$olchu','$meqsed','$qesebe','$hide','$foto','$foto2','$foto3','$foto4','$foto5')",$db);
}//if (isset($_FILES['foto']))
else {
$sendto = " Files type only jpg, jpeg, gif and png";
}
}
else {$sendto = ""Files max size 512kb";}
echo "<p style='font-family:Arial, Helvetica, sans-serif; color:#F00; font-size:14px; font-weight:bold; '>$sendto</p>";
}//else
;}
//COMMENT: if ($nov !== "Torpaq")
if ($nov !== "Torpaq" OR empty ($saa) OR empty ($nov) OR empty ($price2) OR empty ($rayon22) OR empty ($tel) OR empty ($kv) OR empty ($meqsed) OR empty ($address) OR empty ($qesebe) OR empty ($hide) OR empty ($text))
{
if ($nov === "Torpaq"){
echo "<p style='font-family:Arial, Helvetica, sans-serif; color:#F00; font-size:16px; font-weight:bold; '>Pleas Fill all</p>";}
}
else
{
if ($_FILES['foto']['size'] <= 524288 or $_FILES['foto2']['size'] <= 524288 or $_FILES['foto3']['size'] <= 524288 or $_FILES['foto4']['size'] <= 524288 or $_FILES['foto5']['size'] <= 524288)
{
$allowed = array('image/jpeg', 'image/jpg', 'image/gif', 'image/png', 'image/pjpeg', 'images/x-png', '');
if (isset($_FILES['foto']) && in_array($_FILES['foto']['type'], $allowed) or isset($_FILES['foto2']) && in_array($_FILES['foto2']['type'], $allowed) or isset($_FILES['foto3']) && in_array($_FILES['foto3']['type'], $allowed) or isset($_FILES['foto4']) && in_array($_FILES['foto4']['type'], $allowed) or isset($_FILES['foto5']) && in_array($_FILES['foto5']['type'], $allowed)) {
if (file_exists($_FILES['foto']['tmp_name']) && is_file($_FILES['foto']['tmp_name']) && in_array($_FILES['foto']['type'], $allowed) or file_exists($_FILES['foto2']['tmp_name']) && is_file($_FILES['foto2']['tmp_name']) && in_array($_FILES['foto2']['type'], $allowed) or file_exists($_FILES['foto3']['tmp_name']) && is_file($_FILES['foto3']['tmp_name']) && in_array($_FILES['foto3']['type'], $allowed) or file_exists($_FILES['foto4']['tmp_name']) && is_file($_FILES['foto4']['tmp_name']) && in_array($_FILES['foto4']['type'], $allowed) or file_exists($_FILES['foto5']['tmp_name']) && is_file($_FILES['foto5']['tmp_name']) && in_array($_FILES['foto5']['type'], $allowed))
{
if ( strlen( $_FILES['foto']['name'] ) > 150 or strlen( $_FILES['foto2']['name'] ) > 150 or strlen( $_FILES['foto3']['name'] ) > 150 or strlen( $_FILES['foto4']['name'] ) > 150 or strlen( $_FILES['foto5']['name'] ) > 150)
{$sendto = "Files name so long";}
else
{ $ndate = date ('Ymdhis');
$foto="img"."$ndate"."{$_FILES['foto']['name']}";
if (empty ($_FILES['foto']['name'])) {$foto="nophoto.jpg";}
move_uploaded_file($_FILES['foto']['tmp_name'], "images/$foto");
$foto2="img2"."$ndate"."{$_FILES['foto2']['name']}";
if (empty ($_FILES['foto2']['name'])) {$foto2="";}
move_uploaded_file($_FILES['foto2']['tmp_name'], "images/$foto2");
$foto3="img3"."$ndate"."{$_FILES['foto3']['name']}";
if (empty ($_FILES['foto3']['name'])) {$foto3="";}
move_uploaded_file($_FILES['foto3']['tmp_name'], "images/$foto3");
$foto4="img4"."$ndate"."{$_FILES['foto4']['name']}";
if (empty ($_FILES['foto4']['name'])) {$foto4="";}
move_uploaded_file($_FILES['foto4']['tmp_name'], "images/$foto4");
$foto5="img5"."$ndate"."{$_FILES['foto5']['name']}";
if (empty ($_FILES['foto5']['name'])) {$foto5="";}
move_uploaded_file($_FILES['foto5']['tmp_name'], "images/$foto5");
}
}
if (empty($foto)) {$foto='nophoto.jpg';}
$result3 = mysql_query ("INSERT INTO data (nov,saa,address,tel,mail,price2,text,rayon2,kv,olchu,meqsed,qesebe,hide,foto,foto2,foto3,foto4,foto5) VALUES ('$nov','$saa','$address','$tel','$mail','$price2','$text','$rayon2','$kv','$olchu','$meqsed','$qesebe','$hide','$foto','$foto2','$foto3','$foto4','$foto5')",$db);
}//if (isset($_FILES['foto']))
else {
$sendto = "Files type only jpg, jpeg, gif and png";
}
}
else {$sendto = "Files max size 512kb";}
echo "<p style='font-family:Arial, Helvetica, sans-serif; color:#F00; font-size:14px; font-weight:bold; '>$sendto</p>";
}//else
}//if isset SUBMIT2
?>