title: script to upload a file without submit
body: <p>I have the below code to upload a photo.  I currently have the process set so it uploads upon click of a submit button.  How can I change this code to upload automatically without the submit button? Thanks</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;form data-ajax="false" id="imageform" action="imageup.php" method="POST" enctype="multipart/form-data" name="form"&gt;
      &lt;a id="companylink" href=""&gt;
          &lt;div id="yourBtn" onclick="getFile()" onchange="readURL(this);"&gt;
              &lt;img id="companyprofileimg" src="image/&lt;?php echo $row['photo']?&gt;"/&gt;
          &lt;/div&gt;
          &lt;span id="cetext"&gt;&lt;?php echo $row['username']?&gt;&lt;/span&gt;
      &lt;/a&gt;
      &lt;div style='height: 0px;width: 0px; overflow:hidden;'&gt;
          &lt;input id="upfile" type="file" value="upload" name="file" onchange="readURL(this);"/&gt;
      &lt;/div&gt;
      &lt;a data-theme="g" data-ajax="false" data-role="button" id="imagesub" onclick="$('#imageform').submit();" aria-disabled="false"&gt;Upload Image&lt;/a&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>JAVASCRIPT:</strong></p>
  
  <pre><code> function getFile(){
     document.getElementById("upfile").click();
   }
   function sub(obj){
      var file = obj.value;
      var fileName = file.split("\\");
      document.getElementById("companyprofileimg").innerHTML = fileName[fileName.length-1];
      document.myForm.submit();
      event.preventDefault();
      document.getElementById('imageform').submit();
    }
  </code></pre>