How do I send files via HTTP request using Axios and get them in the server?

  axios, file-upload, httprequest, ionic-framework, laravel

I’m using Ionic with Vue 3 and Axios to post data.

I have this in my post request:, {name, image});

And I get them in my PHP side like this:

echo $request->input("name");
echo $request->file("image");

I’m able to get the name but the problem is that I can’t get the image. I can see that the image is being posted.

I also tried:, {name, image}, {
             "Content-Type": "multipart/form-data"

But no success. The form is also multipart/form-data.

So my question is:

How do I get the image posted via Axios in PHP?

Source: Laravel

Leave a Reply