upload
This commit is contained in:
parent
dbe8f49a46
commit
274c93b86f
5
scripty/dano.js
Normal file
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>
|
||||
<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>
|
||||
<table id="tabulka"></table>
|
||||
|
||||
<form action="upload.php" method="post" enctype="multipart/form-data">
|
||||
Vyber si súbor na nahratie:
|
||||
<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>
|
||||
</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>
|
43
upload.php
43
upload.php
@ -1,42 +1,43 @@
|
||||
<?php
|
||||
$target_dir = "stranky/";
|
||||
$target_dir = "uploads/";
|
||||
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
|
||||
$uploadOk = 1;
|
||||
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
|
||||
|
||||
// Check if image file is a actual image or fake image
|
||||
if(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;
|
||||
}
|
||||
}
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST["submit"])) {
|
||||
|
||||
// Check if file already exists
|
||||
if (file_exists($target_file)) {
|
||||
// Check if file already exists
|
||||
if (file_exists($target_file)) {
|
||||
echo "Sorry, file already exists.";
|
||||
$uploadOk = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Check file size
|
||||
if ($_FILES["fileToUpload"]["size"] > 500000) {
|
||||
// Check file size
|
||||
if ($_FILES["fileToUpload"]["size"] > 500000) {
|
||||
echo "Sorry, your file is too large.";
|
||||
$uploadOk = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if $uploadOk is set to 0 by an error
|
||||
if ($uploadOk == 0) {
|
||||
// Check if $uploadOk is set to 0 by an error
|
||||
if ($uploadOk == 0) {
|
||||
echo "Sorry, your file was not uploaded.";
|
||||
// if everything is ok, try to upload file
|
||||
} else {
|
||||
// if everything is ok, try to upload file
|
||||
} else {
|
||||
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
|
||||
echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.";
|
||||
} else {
|
||||
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>";
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user