Skip to content
Advertisement

jquery – upload image file using ajax is not working

I want to submit my image via jquery and ajax , this is my code:

JavaScript

just to add some explanation , when the use choose an image , the form submits immediately .

it works fine and post the data to my php page , but it’s empty and has no data

I put print_R($_POST) in my page and the result is

JavaScript

( )

I logged the ajax post and there was no data posting .

what is the problem ?

Advertisement

Answer

Your image is probably in PHP array $_FILES. You must download your file from it to get your image.

JavaScript

You have also to add “name” attribute to your input:

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