一起源码网

  • www.171739.xyz
  • 全球最大的互联网技术和资源下载平台
搜索
猜你喜欢
查看: 9166|回复: 1
打印 上一主题 下一主题

如何利用php进行文件扩展名判断

[复制链接]

0

主题

0

帖子

1万

积分

钻石会员

Rank: 8Rank: 8

积分
17424
QQ
跳转到指定楼层
楼主
发表于 2020-4-29 16:30 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式
<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-type" content="text/html" charset="utf-8">
    <title>check file</title>
</head>
<body>
<b>文件扩展名验证</b>
<input type="text" name="int" value="文件.php" onblur="check(this)" id="int">
<input type="button" value="检测" onclick="check_value()">
<script>    function check(obj){        
    if(obj.value == "" || obj.value.length<3){
            alert("输入的长度不能小于3且不能为空!");
            obj.focus();
        }
    }    function check_value(){        var str = $("int").value;        var repx = /.(php|asp|jsp)$/i;        var type = str.substring(str.lastIndexOf("."),str.length);        if(type.match(repx) && str.lastIndexOf(".") != -1){
            alert("文件扩展名正确");
            $("int").focus();
        }else{
            alert("文件扩展名有误");
            $("int").focus();
        }
    }    function $(obj){        return document.getElementById(obj);
    }</script>
</body>
</html>

分享到:  QQ好友和群QQ好友和群
收藏收藏
回复

使用道具 举报

0

主题

21

帖子

65

积分

注册会员

Rank: 2

积分
65
沙发
发表于 2022-10-1 06:59 来自手机 | 只看该作者
qq号交易平台
回复

使用道具 举报

一起源码让程序更轻更快

www.171739.xyz

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表