<form id="upload_form" enctype="multipart/form-data" method="post" action="upload.php" ><input id="img" name="img" type="file" accept="image/*" onChange="fileSelected()" ><input id="img" name="img2" type="file" accept="image/*" onChange="fileSelected()" ><input type="button" value="上传" id="send" onClick="startUploading()" /></form><script>var send=document.getElementById("send"); send.onclick=function() { var file=document.getElementById("img").value; var file=document.getElementById("img2").value; if (file.length<1) { alert('请选择图片'); return false; } }</script>