Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

406
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda