PHP头条
热点:

php批量上传一[带预览]


代码如下:

<?php
require('inc/conn.php');
?>
<head>
<head>
<meta http-equiv="Content-Type" c />
<title>图片上传实现</title>
<script language="javascript">
function preview(x){
    if(!x || !x.value) return;
    var patn = /.jpg$|.jpeg$|.gif$/i;
    if(patn.test(x.value)){
        if(x.parentNode.nextSibling.firstChild){
            //看看是不是已经添加了图片标签,如果添加了就直接修改图片地址
            x.parentNode.nextSibling.firstChild.setAttribute('src','file://localhost/'+x.value);
        }else{
            //没添加就创建个咯,然后加入到当前节点的父节点的下一个节点 -_-
            var img = document.createElement('img');
            img.setAttribute('src','file://localhost/'+x.value);
            img.setAttribute('width',120);
            img.setAttribute('height',100);
            x.parentNode.nextSibling.appendChild(img);
            //parentNode  父节点
            //nextSibling 下个节点
            //appendChild 添加个子节点
                        return(x.value);
        }
    }else{
        alert('貌似你选的不是个图片的说!');
        x.value='';                            //本人不懂js,考来的,对不住各位了,也谢谢原作者!
    }
}
</script>
</head>
</head>
<body>

www.phpzy.comtrue/php/9662.htmlTechArticlephp批量上传一[带预览] 代码如下: ?php require('inc/conn.php'); ? head head meta http-equiv=Content-Type c / title图片上传实现/title script language=javascript function preview(x){ if(!x || !x.value) return; var patn = /.j...

相关文章

    暂无相关文章
相关频道:

PHP之友评论

今天推荐