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
HTML:
<form data-ajax="false" id="imageform" action="imageup.php" method="POST" enctype="multipart/form-data" name="form">
<a id="companylink" href="">
<div id="yourBtn" onclick="getFile()" onchange="readURL(this);">
<img id="companyprofileimg" src="image/<?php echo $row['photo']?>"/>
</div>
<span id="cetext"><?php echo $row['username']?></span>
</a>
<div style='height: 0px;width: 0px; overflow:hidden;'>
<input id="upfile" type="file" value="upload" name="file" onchange="readURL(this);"/>
</div>
<a data-theme="g" data-ajax="false" data-role="button" id="imagesub" onclick="$('#imageform').submit();" aria-disabled="false">Upload Image</a>
</form>
JAVASCRIPT:
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();
}