mirror of
https://github.com/anatolykopyl/file-directory.git
synced 2026-03-26 12:54:30 +00:00
File upload
This commit is contained in:
10
main.js
10
main.js
@@ -4,7 +4,7 @@ $(document).on('click', 'div.dropdown-menu', function (e) {
|
||||
|
||||
const buttons = document.querySelectorAll('.delete-button')
|
||||
buttons.forEach((button) => {
|
||||
button.addEventListener("click", async function(event) {
|
||||
button.addEventListener("click", async function (event) {
|
||||
const response = await fetch("delete.php", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -14,4 +14,12 @@ buttons.forEach((button) => {
|
||||
body: `file=${event.target.dataset.file}`
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
const fileInput = document.getElementById('upload');
|
||||
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 });
|
||||
});
|
||||
Reference in New Issue
Block a user