This commit is contained in:
Dávid Jančár 2024-05-29 11:51:16 +02:00
parent dbe8f49a46
commit 274c93b86f
6 changed files with 40 additions and 269 deletions

5
scripty/dano.js Normal file

@ -0,0 +1,5 @@
document.onload = function () {
const response = fetch("/upload.php");
const tabulka = document.getElementById("tabulka");
tabulka.innerHTML = response.text;
}

@ -1,59 +1,7 @@
<!DOCTYPE html> <table id="tabulka"></table>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"
integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A=="
crossorigin="anonymous" referrerpolicy="no-referrer">
<link rel="stylesheet" href="/global/global.css">
<script src="/global/global.js"></script>
<title>Slovanská mytológia</title>
</head>
<nav class="topnav container_menu" id="myTopnav">
<a href="/David">Dávid</a>
<a href="/Dano" class="active">Daniel</a>
<a href="javascript:void(0);" class="icon" onclick="myFunction()"></a>
</nav>
<body>
<table border="5px" align="right">
<tr>
<th>Názov súboru</th>
<th>Download</th>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><img src="#" alt="image"></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><img src="#" alt="image"></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><img src="#" alt="image"></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><img src="#" alt="image"></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><img src="#" alt="image"></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><img src="#" alt="image"></td>
</tr>
</table>
<form action="upload.php" method="post" enctype="multipart/form-data"> <form action="/upload.php" method="post" enctype="multipart/form-data">
Vyber si súbor na nahratie: Vyber súbor na nahratie:
<input type="file" name="fileToUpload" id="fileToUpload"> <input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Nahrať súbor" name="submit"> <input type="submit" value="Nahrať súbor" name="submit">
</form> </form>
</form>
</body>
</html>

@ -1,61 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"
integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A=="
crossorigin="anonymous" referrerpolicy="no-referrer">
<link rel="stylesheet" href="/global/global.css">
<script src="/global/global.js"></script>
<title>Slovanská mytológia</title>
</head>
<nav class="topnav container_menu" id="myTopnav">
<a href="/David" class="active">Dávid</a>
<a href="stranky/Dano.html">Daniel</a>
<a href="javascript:void(0);" class="icon" onclick="myFunction()"></a>
</nav>
<body>
<main>
<table border="5px" align="right">
<tr>
<th>Názov súboru</th>
<th>Download</th>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><a href="#" download="white-download-icon-21"><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></a></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><a href="#" download="white-download-icon-21"><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></a></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><a href="#" download="white-download-icon-21"><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></a></td>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><a href="#" download="white-download-icon-21"><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></a></td>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><a href="#" download="white-download-icon-21"><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></a></td>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><a href="#" download="white-download-icon-21"><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></a></td>
</table>
<form action="/david.html" method="post" enctype="multipart/form-data">
Vyber súbor na nahratie:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Nahrať súbor" name="submit">
</form>
</form>
</main>
<footer>
<p>Kontakt:</p><br>
<p>d94778894@gmail.com</p>
</footer>
</body>
</html>

@ -1,65 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"
integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A=="
crossorigin="anonymous" referrerpolicy="no-referrer">
<link rel="stylesheet" href="/global/global.css">
<script src="/global/global.js"></script>
<title>Slovanská mytológia</title>
</head>
<nav class="topnav container_menu" id="myTopnav">
<a href="/David" class="active">Dávid</a>
<a href="stranky/Dano.html">Daniel</a>
<a href="javascript:void(0);" class="icon" onclick="myFunction()"></a>
</nav>
<body>
<main>
<table border="5px" align="right">
<tr>
<th>Názov súboru</th>
<th>Download</th>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><a href=""><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></a></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></td>
</tr>
<tr>
<a href="#"><td>SuperSubor</td></a>
<td><img src="white-download-icon-21.jpg" alt="image" width="50px" height="50px"></td>
</tr>
</table>
<form action="upload.php" method="post" enctype="multipart/form-data">
Vyber súbor na nahratie:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Nahrať súbor" name="submit">
</form>
</form>
</main>
<footer>
<p>Kontakt:</p><br>
<p>d94778894@gmail.com</p>
</footer>
</body>
</html>

@ -1,57 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>upload</title>
</head>
<body>
<?php
$conn = mysqli_connect('localhost','root','','example');
if(isset($_POST['submit'])){
$fileName = $_FILES['file']['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
$path = "files/".$fileName;
$query = "INSERT INTO filedownload(filename) VALUES ('$fileName')";
$run = mysqli_query($conn,$query);
if($run){
move_uploaded_file($fileTmpName,$path);
echo "success";
}
else{
echo "error".mysqli_error($conn);
}
}
?>
<table border="1px" align="center">
<tr>
<td>
<form action="Upload.html" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<button type="submit" name="submit"> Upload</button>
</form>
</td>
</tr>
<tr>
<td>
<?php
$query2 = "SELECT * FROM filedownload ";
$run2 = mysqli_query($conn,$query2);
while($rows = mysqli_fetch_assoc($run2)){
?>
<a href="download.php?file=<?php echo $rows['filename'] ?>">Download</a><br>
<?php
}
?>
</td>
</tr>
</table>
</body>
</html>

@ -1,20 +1,11 @@
<?php <?php
$target_dir = "stranky/"; $target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1; $uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image // Check if image file is a actual image or fake image
if(isset($_POST["submit"])) { if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if file already exists // Check if file already exists
if (file_exists($target_file)) { if (file_exists($target_file)) {
@ -39,4 +30,14 @@ if ($uploadOk == 0) {
echo "Sorry, there was an error uploading your file."; echo "Sorry, there was an error uploading your file.";
} }
} }
}
else {
$files = scandir($target_dir);
echo "<tr><th>Názov súboru</th><th>Download</th></tr>";
foreach($files as $file){
$filename = $file;
$filepath = "/uploads/$file";
echo "<tr><td>SuperSubor</td><td><a href='$filepath' download>$filename</a></td></tr>";
}
}
?> ?>