janiskelemen / formvuelar

Vue form components with server-side validation in mind

Home Page:https://janiskelemen.github.io/formvuelar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FvlForm.vue

Barrykilby opened this issue · comments

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

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

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

I have added your fix to version 0.1.18