From 274c93b86fec1c697dd3364e79bab2151e5ad06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Jan=C4=8D=C3=A1r?= Date: Wed, 29 May 2024 11:51:16 +0200 Subject: [PATCH] upload --- scripty/dano.js | 5 ++++ stranky/dano.html | 64 +++++---------------------------------------- stranky/david.html | 61 ------------------------------------------- stranky/domov.html | 65 ---------------------------------------------- stranky/upload.php | 57 ---------------------------------------- upload.php | 57 ++++++++++++++++++++-------------------- 6 files changed, 40 insertions(+), 269 deletions(-) create mode 100644 scripty/dano.js delete mode 100644 stranky/david.html delete mode 100644 stranky/domov.html delete mode 100644 stranky/upload.php diff --git a/scripty/dano.js b/scripty/dano.js new file mode 100644 index 0000000..ec0684d --- /dev/null +++ b/scripty/dano.js @@ -0,0 +1,5 @@ +document.onload = function () { + const response = fetch("/upload.php"); + const tabulka = document.getElementById("tabulka"); + tabulka.innerHTML = response.text; +} \ No newline at end of file diff --git a/stranky/dano.html b/stranky/dano.html index 8bdce55..59a3b15 100644 --- a/stranky/dano.html +++ b/stranky/dano.html @@ -1,59 +1,7 @@ - - - - - - - - - - - Slovanská mytológia - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Názov súboruDownload
SuperSuborimage
SuperSuborimage
SuperSuborimage
SuperSuborimage
SuperSuborimage
SuperSuborimage
+
-
- Vyber si súbor na nahratie: - - -
- - - \ No newline at end of file +
+ Vyber súbor na nahratie: + + +
\ No newline at end of file diff --git a/stranky/david.html b/stranky/david.html deleted file mode 100644 index 9b58cd6..0000000 --- a/stranky/david.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - Slovanská mytológia - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
Názov súboruDownload
SuperSuborimage
SuperSuborimage
SuperSuborimage
SuperSuborimage
SuperSuborimage
SuperSuborimage
- -
- Vyber súbor na nahratie: - - -
- -
- - - \ No newline at end of file diff --git a/stranky/domov.html b/stranky/domov.html deleted file mode 100644 index 7329fd9..0000000 --- a/stranky/domov.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - Slovanská mytológia - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Názov súboruDownload
SuperSuborimage
SuperSuborimage
SuperSuborimage
SuperSuborimage
SuperSuborimage
SuperSuborimage
- -
- Vyber súbor na nahratie: - - -
- -
- - - \ No newline at end of file diff --git a/stranky/upload.php b/stranky/upload.php deleted file mode 100644 index f90b782..0000000 --- a/stranky/upload.php +++ /dev/null @@ -1,57 +0,0 @@ - - - - - upload - - - - - - - - - - - - -
-
- - -
-
- - Download
- -
- - - diff --git a/upload.php b/upload.php index e3d7ff4..c806734 100644 --- a/upload.php +++ b/upload.php @@ -1,42 +1,43 @@ 500000) { + echo "Sorry, your file is too large."; + $uploadOk = 0; + } -// 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) { - echo "Sorry, your file was not uploaded."; -// 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."; + // 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 { - echo "Sorry, there was an error uploading your file."; + 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 "Názov súboruDownload"; + foreach($files as $file){ + $filename = $file; + $filepath = "/uploads/$file"; + echo "SuperSubor$filename"; } } ?> \ No newline at end of file