jquery文件框inputfile改变事件 校验文件类型

来源:互联网 发布:不配说爱我dj网络歌手 编辑:程序博客网 时间:2024/06/05 20:13
</pre><pre name="code" class="javascript">/** * 验证文件类型 * @param {Object} filepath 获取到的文件路径 * @param {Object} allowtype 允许通过的文件类型数组如 图片: [ "jpg", "gif","png","Jpeg"] */function checkfiletype(filepath,allowtype){//截取文件后缀名var thisfiletype = filepath.substring(filepath.lastIndexOf(".")+1,filepath.length).toLowerCase();if ($.inArray(thisfiletype,allowtype) == -1){return false;}else {return true;}}


2 0
原创粉丝点击