diff --git a/src/main/resources/static/js/script.js b/src/main/resources/static/js/script.js index 3f11fc0..666e470 100644 --- a/src/main/resources/static/js/script.js +++ b/src/main/resources/static/js/script.js @@ -39,4 +39,22 @@ function deleteSelected() { form.action = '/files/bulk-delete'; // Backend endpoint for bulk delete form.submit(); } +} + +// Handle file upload, check file type +function validateFile() { + const fileInput = document.getElementById('file'); + const file = fileInput.files[0]; + const allowedMimeTypes = ['audio/', 'video/']; + + if (file) { + const fileType = file.type; + if (!allowedMimeTypes.some((type) => fileType.startsWith(type))) { + alert('File type is not an audio or video file.\nPlease select an audio or video file to upload.'); + fileInput.value = ''; + return false; + } + } + + return true; } \ No newline at end of file diff --git a/src/main/resources/templates/file-management.html b/src/main/resources/templates/file-management.html index dda4084..b32d62b 100644 --- a/src/main/resources/templates/file-management.html +++ b/src/main/resources/templates/file-management.html @@ -34,7 +34,8 @@
- +