Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

419
Visualizações
Vuex+Laravel: Can't send multiple files with FormData and axios to server side. Always getting null on server side. What's going on?

The information which I got by my previous question Vuex + Laravel. Why axios sends any values but only not that one, which come's with method's parameter? works only for situation when I pass only one argument in axios. I also found how to successfully pass multiple files with one argument, but in my situation, I have to use object, to be able to pass more than one argument. So instead of

const response = await axios.post('/posts', data)

I have to use the next one

const response = await axios.post('/posts', {
                formData:data,
                body:postBody
            })

I thought it would be easy, but now is the 5-th hour that I can't find the solution.

enter image description here

controller

public function store(Request $request)
    {
        $files = $request->all();
        return var_dump($files);
    }

I tried many things, included $request->allFiles() and getClientOriginalExtension() experiments. No results. What versions do you have? How this problem can be fixed?

Important! I use Laravel, vuex, axios.
I use text not in FormData cause it's textArea. And if I can combinate textarea in FormData to make one argument axios call, anyway it still very important to me to know what's the problem which I described above.

Updated

Here's chrome's payload tab

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It's not pretty clear why you don't send everything you need within formData object.

You could do something like:

const formData = new FormData()

formData.append(body, postBody)
formData.append(files, fileList)
formData.append(otherData, someOtherData)

const response = await axios.post('/posts', formData)

Then in your server side you will be able to do

 $body = $request->body;
 $files = $request->files;
 $otherData = $request->otherData;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda