diff --git a/files/earth.mp4.private b/files/earth.mp4.private deleted file mode 100644 index b11552f..0000000 Binary files a/files/earth.mp4.private and /dev/null differ diff --git a/index.php b/index.php index 6c7d596..c4d54f2 100644 --- a/index.php +++ b/index.php @@ -79,46 +79,22 @@ $filesize = number_format($filesize, 2, ",", " ") . $msr; } - echo "" . $filename; - if ($ext == "private") { - if (isset($_SESSION['loggedin']) && $_SESSION['loggedin']==true) { - echo "download='" . pathinfo($filename, PATHINFO_FILENAME) . "' href='files/" . $filename . "'>" . pathinfo($filename, PATHINFO_FILENAME); - } else { - echo ">" . pathinfo($filename, PATHINFO_FILENAME); - } + echo "" . $filesize . ""; + + if ($ext == "mp4") { + echo "📼"; + } elseif ($clr == " list-group-item-warning") { + echo "🖼️"; } else { - echo "download href='files/" . $filename . "'>" . $filename; + echo "\n"; } - echo "" . $filesize . ""; - if ($ext == "private" && !(isset($_SESSION['loggedin']) && $_SESSION['loggedin']==true)) { - echo "Требуется авторизация"; - } - echo ""; - - if (isset($_SESSION['loggedin']) && $_SESSION['loggedin']==true) { - if ($ext == "mp4") { - echo "📼"; - } elseif ($clr == " list-group-item-warning") { - echo "🖼️"; - } else { - echo "\n"; - } - echo "
\n"; - } else { - if ($ext == "mp4") { - echo "📼"; - } elseif ($clr == " list-group-item-warning") { - echo "🖼️"; - } else { - echo "\n"; - } - if ($clr == " list-group-item-warning") { - echo "
\n"; - } - } echo "🗑"; + + echo "
\n"; echo "
\n"; } } diff --git a/main.js b/main.js index 7accf0f..408aced 100644 --- a/main.js +++ b/main.js @@ -1,7 +1,3 @@ -$(document).on('click', 'div.dropdown-menu', function (e) { - e.stopPropagation(); -}); - const buttons = document.querySelectorAll('.delete-button') buttons.forEach((button) => { button.addEventListener("click", async function (event) { @@ -13,6 +9,10 @@ buttons.forEach((button) => { }, body: `file=${event.target.dataset.file}` }); + if (response.status === 200) { + const deletedRow = document.querySelector(`.list-group-item[data-file='${event.target.dataset.file}']`); + deletedRow.remove(); + } }) }); @@ -21,5 +21,8 @@ fileInput.addEventListener('change', async function (event) { const file = event.target.files[0]; let formData = new FormData(); formData.append("file", file); - fetch('upload.php', { method: "POST", body: formData }); + const response = await fetch('upload.php', { method: "POST", body: formData }); + if (response.status === 200) { + window.location.reload(false); + } }); \ No newline at end of file diff --git a/upload.php b/upload.php index a18a26e..0285279 100644 --- a/upload.php +++ b/upload.php @@ -7,13 +7,13 @@ $filename = $path['filename']; $ext = $path['extension']; $temp_name = $_FILES['file']['tmp_name']; - $path_filename_ext = $target_dir.$filename.".".$ext; + $path_filename_ext = $target_dir . $filename . "." . $ext; // Check if file already exists if (file_exists($path_filename_ext)) { echo "Sorry, file already exists."; - }else{ - move_uploaded_file($temp_name,$path_filename_ext); + } else { + move_uploaded_file($temp_name, $path_filename_ext); echo "Congratulations! File Uploaded Successfully."; } }