Skip to content
Advertisement

React app not sending files to php server with Ajax

I’m hosting a react app on my apache server. I’m using react-images-upload npm package to receive an image from the user then post it to my php server with Axios.

However when I check the php $_FILES array in the response it’s empty.

I have tested wether my server can receive files with a little upload form on the php side, and it worked great, checked memory limits, that the folder on the server is writable and such. When I console.log(thumbnail) I get a file object in the console, so the uploader works

enter image description here

enter image description here

everything seems fine. So I suspect it’s something to do with the Ajax call.

Front end Code:

JavaScript

Backend code:

JavaScript

Any help would be much appreciated.

Advertisement

Answer

I think this:

JavaScript

should be this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement