Nothing getting displayed in Response Header

I have the following files. Nothing is displayed in the Response header of developer tools. I am expecting the variables related to files and post in my accept.php page.

  1. send.php
<?php

echo ' 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

<script type="text/javascript" src="file.js"></script>

<form id="data">
	  <input type="hidden" name="id" value="123" readonly="readonly">
	  User Name: <input type="text" name="username" value=""><br />
	  Profile Image: <input name="profileImg[]" type="file" /><br />
	  Display Image: <input name="displayImg[]" type="file" /><br />
	  <button  type = "button" onclick="submitFileTest()">Submit Button  </button>
    </form>

';

?>
  1. file.js
 function submitFileTest() { 
  
		
		  //grab all form data  
		  var formData = new FormData($(this)[0]);
		  
		  console.log("Form Data Test");
		  console.log(formData);
		 
		  $.ajax({
			url: 'accept.php',
			type: 'POST',
			data: formData,
			async: false,
			cache: false,
			contentType: false,
			processData: false,
			success: function (returndata) {
			  //alert(returndata);
			  console.log(returndata);
			}
		  });
		 

   
	
 }
<?php


        if (isset($_POST['id'])) {                      
            $id = $_POST['id'];
			var_dump($id);
			echo $id;
		}
		
		
		if (isset($_POST['username'])) {
		   $username = $_POST['username'];
		   var_dump($username);
		   echo $username;
		}
		
		
		if (isset($_FILES['profileImg'])) {
		    $profileImg = $_FILES['profileImg'];
			var_dump($profileImg);
			echo $profileImg;
		}
		
		if (isset($_FILES['displayImg'])) {
		     $displayImg = $_FILES['displayImg'];
			 var_dump($displaying);
			 echo $displayImg;
		}
		
		




?>

For me, nothing appears in the PHP $_POST or $_FILES arrays.

If I change the source of the formdata to this:

var formData = new FormData($(data)[0]);

and put something in the username field, then it (and the hidden variable) is sent. As soon as I select an image, though, both $_POST and $_FILES are empty.

I would suggest there’s a JavaScript issue here, rather than a PHP one, and you should perhaps post in that board.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.