POST an image to PHP in AJAX

后端 未结 3 1919
终归单人心
终归单人心 2021-01-27 15:35

I would like to send an image to a php file using AJAX.

Here\'s my JS code:

$.ajax({
    type: \"POST\",
    url: \"http://website.com/a         


        
3条回答
  •  萌比男神i
    2021-01-27 16:30

    Instead of sending the image, the right approach would be to send image in base64 encoded format. On the server side you'll have to decode the base 64 encoded string and save as an image. Follow this link to get a better insight on how to send encoded image.

提交回复
热议问题