web UI: fallback no-js web form for file uploads (#1364)#1560
web UI: fallback no-js web form for file uploads (#1364)#1560stinkerton18 merged 1 commit intodevelopfrom
Conversation
This makes it possible to upload files from a vintage browser, for instance Note that you have to explicitly turn off javascript in the user agent to get the fallback form
|
| <div class="noscriptmsg"> | ||
| {{ _("The file uploading functionality requires JavaScript.") }} | ||
| </div> | ||
| <form id="uploadForm" action="/files/uploadform/" onchange="fileSelect(event)" method="post" enctype="multipart/form-data"> |
There was a problem hiding this comment.
Can the onchange event handler ever run from here?
There was a problem hiding this comment.
It won't ever run because it's inside a <noscript> tag ^^;
I borrowed this form markup from Eric's earlier web upload form from 2021, and forgot to clean up javascript stream upload stuff.
| <script type="application/javascript"> | ||
| document.addEventListener("DOMContentLoaded", function() { | ||
| document.getElementById("js-upload-form").style.display = "block"; | ||
| }); | ||
| </script> |
There was a problem hiding this comment.
I guess the other option would be to progressively enhance a shared form of DOMContentLoaded is fired. Just an observation, I don't think there's a real maintenance burden from having two forms here.
There was a problem hiding this comment.
Right, it felt a little icky to introduce a bunch of code duplication. A similar situation with upload_file() and upload_file_form(). I briefly tinkered with this but I concluded that the effort outweighed the benefit. Something to refactor in the future on a rainy day!
|
@stinkerton18 thanks for your attention to these PRs :) in the future, please hold off on merging a PR with open conversations, such as this one there may be valuable improvements that come out of these conversations, so I think it's important to go through and address each one in fact, I just turned on a branch protection policy that prevents merging with open conversations so this should be a non problem from now on |
|
filed #1565 to address the comments in this PR and add a test |




This makes it possible to upload files from a vintage browser, for instance
Note that you have to explicitly turn off javascript in the user agent to get the fallback form