Multiple Images Binary

Asked

Viewed 10 times

-1

Hello person I’m having a problem, I have to select 3 different images (* currently only taken 1 as per image below) and add them in an array however this array has to be with binary images, I did not find any example and I have no idea how I can do it, I even managed to do this array with objects but not in binary, someone knows how to do this?

inserir a descrição da imagem aqui

Input:

<input  type="file" ref="file" accept="image/*" required multiple @change="uploadFile" />

Date:

data() {
        return {
    
          images: [],
         
        };
      },

Methods:

uploadFile() {
      this.images = this.$refs.file.files[0];
    },

    submitFile(codBarras,descriProd,cat,valor,destaque,descprod,tamanhos,images) {
      const formData = new FormData();
      formData.append("codigoProduto", codBarras); 
      formData.append("descricaoProduto", descriProd); 
      formData.append("nome_categoria", cat);
      formData.append("valor", valor); 
      formData.append("destaque", destaque); 
      formData.append("descricao_pagamento", descprod); 
      formData.append("tamanhos", tamanhos); 
      formData.append("images", images);
      const headers = { "Content-Type": "multipart/form-data" };

      api.post(`/cadastrarProduto`, formData, { headers }).then((res) => {
        res.data.files;
        res.status;
      });
    },
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.