File size: 1.47Kb
<div class="pole">
<?php
if(isset($_POST['save'])){
foreach($_FILES["pictures"]["error"] as $key => $error){
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
if(file_exists("files/$name")){
$name = ''.time().'_'.$name.'';
}
$ras = pathinfo($name, PATHINFO_EXTENSION);
$img = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'wmf');
$ext = array_merge($img);
if (!in_array($ras, $ext)){
err('К загрузке разрешены изображения форматов '. implode(',',$ext));
} else {
if (empty($ras)){
err('Файл не может быть без расширения');
} else {
$name = time().rand(1,299).'.'.$ras;
move_uploaded_file($tmp_name, "files/$name");
$size = $_FILES['pictures']['size'][$key];
mysql_query("INSERT INTO `kont_photo` SET `name` = '" . $name . "', `kont` = '" . $id . "', `user_id` = '" . $user['id'] . "';")or die(mysql_error());
header("Location: write$id");
}
}
}
}
}
//----формы)----//
?>
<form method="post" enctype="multipart/form-data">Выберите фото для загрузки:<br />
<input type="file" name="pictures[]" /><br />
<input type="file" name="pictures[]" /><br />
<input type="file" name="pictures[]" /><br />
<input type="submit" value="<?=$send_mail['send']?>" name="save" /></form>
</div>
<?php
require('../system/inc/footer.php');