X-Git-Url: https://git.p6c8.net/jirafeau/pcanterino.git/blobdiff_plain/9e0eb7719c3ce8dd8052b4c29da5c60033fc1389..08b9270797ef139d44343187cfa545a145021d83:/lib/functions.js.php diff --git a/lib/functions.js.php b/lib/functions.js.php index cafecaf..b178f4f 100644 --- a/lib/functions.js.php +++ b/lib/functions.js.php @@ -351,6 +351,19 @@ function control_selected_file_size(max_size, error_str) } } +// UX-only: script.php enforces disallowed_extensions independently, this +// just warns the user before they submit a doomed upload. +function control_selected_file_extension(disallowed_extensions, error_str) +{ + f_name = document.getElementById('file_select').files[0].name; + f_ext = f_name.includes('.') ? f_name.split('.').pop().toLowerCase() : ''; + if (disallowed_extensions.includes(f_ext)) + { + pop_failure(error_str); + document.getElementById('send').style.display = 'none'; + } +} + function XHRErrorHandler(e) { var text = "${e.type}: ${e.loaded} bytes transferred"