x
 
<!DOCTYPE html>
<html>
<body>
<form id="myForm">
  请选择要上传的文件:
  <input type="file" id="myFile">
</form>
<p>点击下方按钮,显示上方文件按钮所属表单的id。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
  var x = document.getElementById("myFile").form.id;
  document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>