file-upload-with-preview icon indicating copy to clipboard operation
file-upload-with-preview copied to clipboard

May I use html_form submit to backend?

Open cin-yi-wei opened this issue 2 years ago • 1 comments

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.

cin-yi-wei avatar May 14 '22 16:05 cin-yi-wei

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.

johndatserakis avatar May 15 '22 03:05 johndatserakis

Let me know if I can help further, thanks.

johndatserakis avatar Oct 14 '22 02:10 johndatserakis