title: how to send/upload file using jquery or javascript?
body: <p>How to send/upload file information to php using jquery ajax?
  info is the file  to be uploaded.</p>
  
  <pre><code>$.ajax({
              type: "POST",
              url: url,
              data: data, /* data from input file to upload it */
              async: false,
              beforeSend: function() {
              },
              complete: function() {
  
              },        
              cache: false,
              success: callback,
              error: function(error) {
                  alert("Some problems have occured. Please try again later: " + error);
              }
          });
  
  &lt;form id="product-form" action="javascript: product();" enctype="multipart/form-data"&gt;
  &lt;input type="file" name="img" /&gt;
  &lt;a href="#" class="link2" onclick="document.getElementById('product-form').submit()"&gt;Submit&lt;/a&gt; 
  &lt;/form&gt;
  </code></pre>