zoukankan      html  css  js  c++  java
  • PHP多文件上传

    
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset=utf-8>
        <meta name=description content="">
        <meta name=viewport content="width=device-width, initial-scale=1">
        <title>多文件上传</title>
        <style>
            table tr td{200px;height:30px;}
            table tr{text-align:center;}
        </style>
    </head>
    <body>
        <form action="index.php" method="post" accept-charset="utf-8" enctype="multipart/form-data" name="form1">
            <table border="1">
                <tbody>
                    <tr>
                        <td>内容1</td><td><input type="file" name="picture[]"></td>
                    </tr>
                    <tr>
                        <td>内容2</td><td><input type="file" name="picture[]"></td>
                    </tr>
                    <tr>
                        <td>内容3</td><td><input type="file" name="picture[]"></td>
                    </tr>
                    <tr>
                        <td>内容4</td><td><input type="file" name="picture[]"></td>
                    </tr>
                    <tr>
                        <td>操作</td>
                        <td><input type="submit" name="submit" value="提交"></td>
                    </tr>
                </tbody>
            </table>
        </form>
    </body>
    </html>
    <?php
    //判断服务器是否存在uploads文件,不存在则创建一个
        if(!is_dir("./uploads")){
            mkdir("./uploads");
        }
        //删除上传的图片重复的部分
        $array=array_unique($_FILES['picture']['name']);
        foreach ($array as $key => $value) {
           $path="uploads/".$value;
           if($value){
                if(move_uploaded_file($_FILES['picture']['tmp_name'][$key],$path)){
                    $result=true;
                }else{
                    $result=false;
                }
           }
        }
    
        if($result){
            echo "文件上传成功";
            echo "<meta http-equiv="refresh" content=";url=index.php">";
        }else{
            echo "文件上传失败";
            echo "<meta http-equiv="refresh" content=";url=index.php">";
        }
    ?>
    
    
  • 相关阅读:
    查看web访问日志各url shell
    分页公式
    编译hadoop2.6.0源码
    淘宝微信支付
    nodejs hot deployment
    nwjs
    css小技巧
    webpack babel 相关文章
    nodejs web framework
    swiper
  • 原文地址:https://www.cnblogs.com/qixidi/p/10206116.html
Copyright © 2011-2022 走看看