janiskelemen / formvuelar

Vue form components with server-side validation in mind
https://janiskelemen.github.io/formvuelar/
MIT License
300 stars 25 forks source link

FvlForm.vue #3

Closed Barrykilby closed 5 years ago

Barrykilby commented 5 years ago

Hi Janis,

I have been having an issue receiving files uploaded via FvlMultiFile.vue (not tested dropzone), server-side I'm not receiving the files just a string of File, File, File.

From what I can see:

Object.keys(rawData).map(e => { formData.append(e, rawData[e]) })

Is not picking up on the fact there are multiple files in the array representing the multiple files.

Barry

Barrykilby commented 5 years ago

Hi Janis,

This seems to do the trick, I'm no JS boffin so feel free to facepalm!

Object.keys(rawData).forEach(e => { if(rawData[e] instanceof Object) { Object.keys(rawData[e]).forEach(f => { if (rawData[e][f] instanceof File) { formData.append(e+'[]', rawData[e][f]) } else { formData.append(e, rawData[e]) } }); } else { formData.append(e, rawData[e]) } });

Barry

janiskelemen commented 5 years ago

Hi Barry, I’m currently on vacation but I will take a look at it next week. You can also submit a pull request if you already have a fix. 😊

Sent with GitHawk

janiskelemen commented 5 years ago

I have added your fix to version 0.1.18