javascript
JS判断上传文件类型
/*??
?*?判斷圖片類型??
?*/????
function?checkImgType(ths){????
????if?(ths.value?==?"")?{????
????????alert("請上傳圖片");????
????????return?false;????
????}?else?{????
????????if?(!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(ths.value))?{????
????????????alert("圖片類型必須是.gif,jpeg,jpg,png中的一種");????
????????????ths.value?=?"";????
????????????return?false;????
????????}????
????}????
????return?true;????
}???
?
[js] view plain copy
/*判斷上傳文件是否為Excel文件?
*/??
function?LimitAttach()?{??
????var?file=document.getElementById("files").value;??
????var?form1=document.getElementById("form1");??
????var?ext?=?file.slice(file.lastIndexOf(".")+1).toLowerCase();??
????if?("xls"?!=?ext)?{??
????????alert("只能上傳Excle文件");??
????????return?false;??
????}??
????else?{??
????????form1.action="fupload.action?files="+file;??
????????form1.submit();??
????}??
}??
---------------------
作者:mikyz
來源:CSDN
原文:https://blog.csdn.net/mikyz/article/details/69397023
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!
轉載于:https://www.cnblogs.com/asdyzh/p/9824693.html
總結
以上是生活随笔為你收集整理的JS判断上传文件类型的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 远程连接
- 下一篇: gradle idea java ssm