Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post multiple files not working as expected #65

Open
Jacknq opened this issue Apr 16, 2021 · 2 comments
Open

post multiple files not working as expected #65

Jacknq opened this issue Apr 16, 2021 · 2 comments

Comments

@Jacknq
Copy link

Jacknq commented Apr 16, 2021

hi,
when posting files via axios everything works as expected, once i switch to redaxios, the data were not send and serialized same way..

<input
          class="btn btn-secondary"
          ref="finput"
          type="file"
          name="files2upl"
          multiple
          @change="sync"
        >
 sync(e) {
    e.preventDefault();
    this.files2upl = e.target.files;
  }
  /*
        Submits files to the server
      */
  submitFiles() {
    /*          Initialize the form data        */
    let formData = new FormData();
    /*
          Iteate over any file sent over appending the files
          to the form data.
        */
    for (var i = 0; i < this.files2upl.length; i++) {
      let file = this.files2upl[i];
      this.log(file.size + ' '+file.name);  
      formData.append("files", file, file.name);
}


    //redaxios didnt upload anything
  //this.axios
    this.redaxios
      .post(this.vars.servurl + "/file/uploadfiles2", formData, {
        headers: {
          "content-type": "multipart/form-data",
          token: this.vars.token
        }
      })
}
@Jacknq Jacknq changed the title post multiple files not woking as expected post multiple files not working as expected Apr 16, 2021
@porokhva
Copy link

porokhva commented May 16, 2021

@Jacknq because of redaxios use native fetch() in this case you haven't to add header "content-type": "multipart/form-data", just remove it and all will work as excepted

@Jacknq
Copy link
Author

Jacknq commented May 16, 2021

Ok, if I comment out header line it works, nevertheless axios works with that header...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants