title: how to send a file and an input field using JavaScript and Ajax to send a php script
body: <p>Please someone should show me how to do this using javascript. because am using javascript and ajax to load the page that will do the upload and then after use javascript and ajax to submit the form to a php script    </p>
  
  <pre><code>function AddMultipleContact(){
      var xmlhttp;
    if(window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
    } else { // code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  var url = "url.php";
  var group = document.getElementById("select-input").value;
  var file = document.getElementById('file-name').files;
  var variables = "select-input="+group+"&amp;file-name="+file;
  
  xmlhttp.open("POST", url, true);
  // Set content type header information for sending url encoded variables in the request
  xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  
  // Access the onreadystatechange event for the XMLHttpRequest object
  xmlhttp.onreadystatechange = function() {
      if(xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
          var data = xmlhttp.responseText;
          document.getElementById("flash-message").innerHTML = data;
      }
  }
  xmlhttp.send(variables); // Actually execute the request
  </code></pre>
  
  <p>}</p>