POST an image to PHP in AJAX

后端 未结 3 1886
终归单人心
终归单人心 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条回答
  •  长情又很酷
    2021-01-27 16:11

    If your sending your data using a post, The data property should be a json:

    $.ajax({
        type: "POST",
        url: "http://website.com/add-image.php",
        data: {img: img}
    })
    

提交回复
热议问题