Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

407
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!