<title>点击按钮选择文件后立刻提交</title>
accept设置文件类型,去掉后可选择任何文件
<form method="POST" enctype="multipart/form-data" action="1.asp" onsubmit="return checkForm();">
<label for="FileName">
<input type="button" id="btn" value="选择文件" onclick="document.getElementById('FileName').click();" style="background:ccc">
<input type="file" id="FileName" name="FileName" accept="image/gif,image/jpeg,image/jpg,image/png,image/x-icon,capture=camera" onchange="btnchange();" style="display:none">
</label>
<input type="submit" value="提交" name="B1" id="tj" style="display:none"></p>
</form>
<script language=javascript>
function checkForm() {
alert("提交动作,注释掉这两行就会提交到form");
return false;
}
function btnchange(){
document.getElementById('tj').click();
}
</script>