To prove myself to someone who knows little about PHP, I need to work with some awkwardly hacked system designed and created by people who should probably no longer be allowed to program. In principle, it was decided that users are allowed to upload an image for their profile before they actually complete the registration. Simply, right here, in the middle of the registration form, a completely separate form (functionally, it should look the same) with a file upload field, a separate submit button and an image display area. Apparently, the client saw the upload of the AJAX image to another site and decided: "This is cool, we want it!" without actually knowing how the forms work or considering why an unregistered user has to download things starting from
My initial idea was to create an invisible form elsewhere and copy the value of the file field at the click of a button, and then apply for AJAX. This does not work because JavaScript cannot edit the value of a file field. I see.
The second attempt was to create nested forms. With some hacks , I managed to get FireFox to see two forms, but subordinating the internal one gives the external one. "Undefined behavior", I think, is the term. It makes sense you should not embed forms.
So, ignoring the fact that this makes absolutely no sense, and the client really should say that - is there a way to leave the file upload form on a page that can be submitted via AJAX, and clearly located in a different form? I hope to avoid just creating a form elsewhere on the page and clogging it in place with disgusting CSS hacks.
source share