-
Notifications
You must be signed in to change notification settings - Fork 0
/
nahraj_subor.php
37 lines (36 loc) · 1.33 KB
/
nahraj_subor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="expires" content="mon, 27 sep 2010 14:30:00 GMT" />
<link rel="stylesheet" type="text/css" href="style.css">
<title>Nahrávanie súboru</title>
</head>
<body>
<h1>Nahrávanie súboru</h1>
<?php
$uploadDirectory = '';
if(isset($_FILES['subor'])){
$allowedExtensions = array(
'png', 'jpg', 'mp3', 'mp4', 'tsv', 'html'
);
$file = $_FILES['subor'];
$name = $file['name'];
$extension = pathinfo($name, PATHINFO_EXTENSION);
$extension = strtolower($extension);
if(!in_array($extension, $allowedExtensions)){
echo '<p class="dolezite centrovane">Koncovka súboru <strong>' . $extension . '</strong> nie je povolená.</p>';
} else{
$tmpLocation = $file['tmp_name'];
$newLocation = $uploadDirectory . $name;
$move = move_uploaded_file($tmpLocation, $newLocation);
echo '<p class="centrovane">Súbor <strong>' . $name . '</strong> bol práve nahratý.</p>';
}
}
?>
<p class="centrovane"><a href="sprava.php">Späť na správu kvízov</a></p>
</body>
</html>