0

I am processing in vuejs.

Template:

<b-form @submit.prevent="uploadFile">
  <b-form-file
     v-model="file"
     placeholder="Choose image..."
  />
</b-form>

data() {
  return: {
    file:null
  }
},

methods: {
    uploadFile() {
    console.log(this.file) // result :{$path: "", name: "test2-1591953691.jpeg", lastModified: 1626842100154}
      axios
        .post("/api/upload/store", {
            file: this.file,
        })
        .then((res) => {
          console.log(res.data);
        })
        .catch((error) => {
          console.log(error);
        });
    },
  },

Why is the path null, is there any way to get the path. Please give me ideas, thanks.

  • Does this answer your question? [How to post a file from a form with Axios](https://stackoverflow.com/questions/43013858/how-to-post-a-file-from-a-form-with-axios) – Ohgodwhy Jul 21 '21 at 07:43
  • Thank you. I followed this. But the result still get path null –  Jul 21 '21 at 07:59

0 Answers0