<?php
    header('Content-type:text/html;charset=utf-8');
//    $path=  pathinfo($_FILES['myfile']['name']);
//    echo $path['extension'].'<br>';
    if(isset($_POST['submit'])){
        if(is_uploaded_file($_FILES['myfile']['tmp_name'])){
                $arr=pathinfo($_FILES['myfile']['name']);
                $newName=  date('YmdGis').rand(1000,9999);
                $fileupdate= date('Ymd').rand(1000,9999);
                $fileupname=  mkdir("upload/{$fileupdate}");
                if(move_uploaded_file($_FILES['myfile']['tmp_name'], "upload/{$fileupdate}/{$newName}.{$arr['extension']}")){
                echo '恭喜你上传成功';
                }  else {
                    echo '上传失败';
                }
        }else{
            exit('可能有攻击,请遵守法律!');
        }
        
    }
?>
<! DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <title>上传页面</title>
    </head>
    <body>
        <form action="" method="post"  enctype="multipart/form-data">
            <input type="file" name="myfile" />
            <input type="submit" name="submit" value="开始上传"/>
        </form>
    </body>
</html>

 

相关文章:

  • 2022-12-23
  • 2021-12-10
  • 2021-08-16
  • 2021-11-08
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-02-05
猜你喜欢
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2021-04-25
  • 2022-12-23
  • 2021-06-11
  • 2021-08-25
相关资源
相似解决方案