Friday 17 September 2021

Axios POST not working for image upload

I found that this guy had also $_FILES['image'][tmp_name] empty issue:

https://stackoverflow.com/questions/62604318/files-is-empty-when-sending-a-post-request-using-axios-in-reactjs

In my case, it was 2MB upload_max_filesize in php.ini. Please see PHP - empty $_POST and $_FILES - when uploading larger files I pulled out my hair for 2 hours. Nothing wrong with Axios. I didn't need to specify headers.