Form data submission with optional file uploads #539
Replies: 1 comment
-
|
hey @quinnturner Without making fairly big changes to the internal code, I dont think it will be possible to work around this, and I dont see that happening. In the scenario of no files, I'd suggest simply issuing a simple POST request to the same endpoint using XHR/Fetch or Axios if you like. Uploady doesnt give you any real benefit when there are no files. However, I do understand the desire to have everything in one place, so there is at least one "hack" I can think of. It would require your server to "play along" as what I have in mind is whenever you only want to send the name(s) to delete, you could create a dummy File object and send it along. This will make Uploady issue the request. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, I have the following
Uploadyimplementation:The form is all about managing files. A complete submission includes the following properties as form data:
filesto uploadfileNamesToDelete(string[] | null) list of files that are to be deleted from the backendIn other words, if the current state is that file A is already uploaded, you can upload files B and C and delete file A in one
Saveaction (one network request).To submit the form, I use:
This works well, nice! I can include the
fileNamesToDeletewithin the submission when uploading new files.Unfortunately, when a user tries just to delete a set of files (and not upload a new file),
processPendingwill not submit the form. I have not been able to identify an approach that allows me to submit the form without including a file in the submission.My goal is to support the following actions (✅ explains that it currently works, ❌ is for what doesn't currently work):
a) ✅ Submit a set of files (
filesarray is populated,processPendingwill know to submit)b) ❌ Delete a set of files (
filesarray is empty,processPendingwill avoid submitting)c) ✅ A set of files should be uploaded, and another set should be deleted (
filesarray is populated,processPendingwill know to submit and will include thefileNamesToDelete)c) ✅ NOT submit when there are no files to upload or delete (
filesarray is empty,processPendingwill avoid submitting)Beta Was this translation helpful? Give feedback.
All reactions