这个筛选是浏览器自己的事情,除非你做一个插件。否则只能通过javascript实现控制
<script type="text/javascript" language="JavaScript">
function check() {
  var ext = document.f.pic.value;
  ext = ext.substring(ext.length-3,ext.length);
  ext = ext.toLowerCase();
  if(ext != 'jpg') {
    alert('You selected a .'+ext+
          ' file; please select a .jpg file instead!');
    return false; }
  else
    return true; }
</script><form method="post" name=f
enctype="multipart/form-data"
onsubmit="return check();"
action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi">
<p>
Please select a JPEG (.jpg) file to be sent:
<br>
<input type="file" name="pic" size="40"
accept="image/jpeg">
<p>
Please include a short explanation:<br>
<textarea name="expl" rows="3" cols="40"
onfocus="check();">
</textarea>
<p>
<input type="submit" value="Send">
</form>  

解决方案 »

  1.   

    哦,这样的啊,不能在文件类型那一栏下面拥有选择的类型么?就像word打开文件时的对话框那样
      

  2.   

    原本有一个accept的属性,不过貌似在弹出框中木有效果:
    <form action="form_action.asp" accept="image/gif, image/jpeg">
      Your image: <input type="file" name="pic" id="pic" /><br />
      <input type="submit" value="Submit" />
    </form>
    如果一定要判断的话,那借助JS来判断了,可以参考:EasyValidate