• 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">";
        }
    ?>
    
    
  • 相关阅读:
    Android 动画
    Eclipse设置软tab(用4个空格字符代替)及默认utf-8文件编码(unix)
    android ANR
    Android 服务端开发之开发环境配置
    安装Android sdk 4.4(19)出现问题的解决方案
    adb uninstall/pull/push 命令的使用总结
    Android学习笔记1 android adb启动失败问题 adb server is out of date. killing...
    Android.mk文件语法规范 原文
    Android MediaProvider数据库模式
    Android MVC模式
  • 原文地址:https://www.cnblogs.com/qixidi/p/10206116.html
Copyright © 2020-2023  润新知