diff options
| author | ilotterytea <iltsu@alright.party> | 2025-03-20 03:02:53 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-03-20 03:02:53 +0500 |
| commit | 16fc341e025671abf45a9b883923b9afe1ea7787 (patch) | |
| tree | 4e882ff86f54f16325dc128826d293f4c57f2c77 | |
| parent | 3eff0dc4b39dc2f0d5bb5b0b13417fe9aa876c48 (diff) | |
fix: file mimetypes in input
| -rw-r--r-- | public/index.php | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/public/index.php b/public/index.php index 5d3668e..36e50c8 100644 --- a/public/index.php +++ b/public/index.php @@ -1,20 +1,6 @@ <?php include_once $_SERVER['DOCUMENT_ROOT'] . '/../config.php'; include_once $_SERVER['DOCUMENT_ROOT'] . '/../lib/partials.php'; - -$accepted_mime_types = []; - -foreach (FILE_ACCEPTED_MIME_TYPES as $k => $v) { - $m = []; - - foreach ($v as $z) { - array_push($m, "$k/$z"); - } - - array_push($accepted_mime_types, implode(', ', $m)); -} - -$accepted_mime_types = implode(', ', $accepted_mime_types); ?> <html> @@ -36,7 +22,9 @@ $accepted_mime_types = implode(', ', $accepted_mime_types); <div class="content"> <form class="column gap-8" action="/upload.php" method="post" enctype="multipart/form-data" id="form-upload"> - <input type="file" name="file" accept="<?= $accepted_mime_types ?>" id="form-file"> + <input type="file" name="file" + accept="<?= implode(', ', array_unique(array_values(FILE_ACCEPTED_MIME_TYPES))) ?>" + id="form-file"> <button type="button" id="form-upload-wrapper" style="display: none"> <h1>Click here to start upload</h1> @@ -58,7 +46,7 @@ $accepted_mime_types = implode(', ', $accepted_mime_types); const formUploadWrapper = document.getElementById('form-upload-wrapper'); formUploadWrapper.style.display = 'block'; - + const formSubmitButton = document.querySelector('#form-upload button[type=submit]'); const formFile = document.getElementById('form-file'); |
