Passing Image using Ajax to PHP

后端 未结 3 2242
时光说笑
时光说笑 2020-12-20 02:47

I am trying to pass an image and a title field value to PHP, I usually process file uploads straight with PHP using the $_FILES array, I am not sure how to create/pass this

3条回答
  •  鱼传尺愫
    2020-12-20 02:58

    You can use jQuery file upload plugin

    $('#imgOne').change(function(){ 
    
      $.ajaxFileUpload({
    
            fileElementId: 'imgOne',
            url: "../Controller/ProductController.php",
    
            dataType: 'json',
    
            success: function(response)
            {
             //Success Code Here
            },
    
            error: function()
            {
               //Error Code Here
            }
      });
    });
    

提交回复
热议问题