vue-dropzone icon indicating copy to clipboard operation
vue-dropzone copied to clipboard

Submit with my form using axios and handle response

Open mohammedpatla opened this issue 6 years ago • 4 comments

As i could not find an example for this i am raising a question.

I am trying to upload files with a form. I already have a JSON object ready(with my form data using formData.append()) to send with a POST function. I am wondering how do i post these images from the dropzone with my data to a server using axios on sendingEvent(file, xhr, formData)?

Or is it not supported? Also if i cant do that how do i handle a response from the dropzone on POST?

EDIT: Should note that i have disable que and am using this.$refs.myVueDropzone.processQueue(); on submit form option. My main concern is if it fails because of form error i will get a response back to my post.

mohammedpatla avatar Nov 03 '19 18:11 mohammedpatla

Hi @mohammedpatla

Did you ever get this resolved? Would probably need to see some more details on your setup.

rowanwins avatar May 09 '20 11:05 rowanwins

Hi, I'm trying to acomplish the same thing.

I have a form that has accepts text and images. If the images get uploaded as soon as dropped, they are orphans, not related to any model, I cannot store them. I need to create the database record first, then using the record ID, to store the images.

I'm surprised there are not more questions for this case scenario.

This is a vuejs project. The form is submited with axios and I need to add one more item with all the uploaded files.

Is this possible with dropzone? Thanks!

dhcmega avatar Sep 06 '20 01:09 dhcmega

Nope, As far as I remember, I never got it to work with the same request, As a workaround, I believe I created a function that did a separate request to submit the form and submit images and connected it on the server end.

@dhcmega I think the reason was that you need to submit images async(in chunks). So if it goes with your form data it gets blocked.

You can close this request if this is not an issue @rowanwins

mohammedpatla avatar Sep 06 '20 04:09 mohammedpatla

@mohammedpatla thanks for responding. I managed to sort of doing it, but images upload as base64, not the actual file. I will keep trying to find a way. Thanks.

dhcmega avatar Sep 06 '20 13:09 dhcmega