0

I have an image upload form with some extra details. I am trying to send image through AJAX to PHP file for further working. This is what i have tried. When i click on submit and check the headers it gives me the following Output. How to resolve it?

action:add
cat_name: Fashion
cat_type:1
cat_switch:1
cat_image:[object File]

AJAX

function ajaxAction(action) {
         var img=$('#cat_image')[0].files[0];
            data = $("#frm_"+action).serialize();
            $.ajax({
                type: "POST",
                url: "response_categories.php",
               data: data+'&cat_image='+encodeURIComponent(img),
                dataType: "json",
                success: function(response)
                {
                    $('#'+action+'_model').modal('hide');
                    $("#categories_grid").bootgrid('reload');
                }

        });
        }

PHP

  print_r($_FILES);
    $fileName = $_FILES['cat_image']['name'];
    $fileType = $_FILES['cat_image']['type'];
    $fileError = $_FILES['cat_image']['error'];
    $fileContent = file_get_contents($_FILES['cat_image']['tmp_name']);
tabia
  • 631
  • 2
  • 10
  • 33

0 Answers0