file-upload-with-preview
file-upload-with-preview copied to clipboard
May I use html_form submit to backend?
I tried to use form submit image array, but serve received an empty image array.
I add change event on input, the event.target.files
is empty.
Hey there.
Sorry if I'm misunderstanding your message, but it seems you are having issues uploading to your backend.
I'm not sure which backend you're using, but that should really matter, as it's all the same really when coming from the frontend.
One thing you could try is using FormData
- it's a way to upload files from your frontend to whatever backend you're using.
Here's one example from stackoverflow of someone using FormData
with axios
. There's a bunch of other examples online of similar methods.
The files from your upload are in the cachedFileArray
, like this:
const upload = new FileUploadWithPreview.FileUploadWithPreview('myFirstImage');
// upload.cachedFileArray;
Loop over those and add them to your FormData
object, then send that to your backend.
If you provide some code examples of what you tried I can perhaps help further.
Let me know if that helps.
Let me know if I can help further, thanks.