How to send mail with multiple file attachements

I have a ContactForm on my Vue.js app that is used to send emails to my Go backend, everything seems to be working fine except the file uploading.

This is the function that pushes the files to the form.

onFileChanged (e) {
  this.files = new FormData()
  for (let i in {
    if ([i].type) {
      let file =[i]

And this is the function that sends the data to my Backend

async sendMail () {
          try {
            await + '/api/email',this.form,
            this.error = false
            this.processed = false
            this.response = true
          } catch (e) {
            this.error = true
            this.processed = false

If I send the form without file attachments everything works fine.

When i attach one or multiple files and console.log the form, the files are present in the form data as an array but the files array in the request is empty.

Console logs of the form i’m sending to the API with axios.

enter image description here

Request payload :


As you can see the files array in the request contains two empty objects [{},{}].

I don’t understand what i did wrong here so any help will be greatly appreciated , thank you.
If you need to see the GO code of the backend just let me know but i’m pretty sure i did something wrong on the frontend.

87 thoughts on “How to send mail with multiple file attachements”

  1. This is the right blog for anyone who wants to find out about this topic. You realize so much its almost hard to argue with you (not that I actually would want?HaHa). You definitely put a new spin on a topic thats been written about for years. Great stuff, just great!