<?php
// upload.php //
if (isset($_FILES['file'])) { $file = $_FILES['file'];
// параметры файла
$file_name = $file['name'];
$file_tmp = $file['tmp_name'];
$file_error = $file['error'];
$file_size = $file['size'];
$file_ext = pathinfo($file_name, PATHINFO_EXTENSION
);
$allowed = array('txt', 'zip');
if ($file_error === 0) {
if ($file_size <= 2097152) {
$file_new_name = uniqid('', true) . '.' . $file_ext; $file_descination = 'uploads/' . $file_new_name;
echo $file_descination;
}
}
}
}
}
?>
// index.php //
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="admin" />
<title>Загрузка файла</title>
</head>
<body>
<form action="upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file"/>
<input type="submit" value="Загрузить"/>
</form>
</body>
</html>