zoukankan      html  css  js  c++  java
  • 每日总结4.25

    <html> 

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">

    <title>文件上传</title>
    <link rel="stylesheet" href="Images/CssAdmin.css">
    </head>

    <body>

    <form enctype="multipart/form-data" action=upfile.php?Result=<?php echo $_GET["Result"];?> method=post>


    <input name=upfile type=file class="button" size=40>

    <input type=submit class="button" value='上传文件'>

    </form>

    </body>

    </html>
    <?php
    error_reporting(0);
    function getname($exname){

    $dir = "uploadfile/";

    $i=1;

    $str = "0123456789abcdefghijklmnopqrstuvwxyz"; // 输出字符集
    $n = 4; // 输出串长度
    $len = strlen($str)-1;
    for($i=0 ; $i<$n; $i++){
    $s .= $str[rand(0,$len)];
    }
    $timestamp=time();



    return $dir.$timestamp.$s.".".$exname;

    }


    $exname=strtolower(substr($_FILES['upfile']['name'],(strrpos($_FILES['upfile']['name'],'.')+1)));

    $uploadfile = getname($exname);


    if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile)) {

    echo "<font color=#ff0000>文件上传成功!</font>";
    echo "<input name='CopyPath' type='button' class='button' value='拷贝文件路径' onclick=CopyPath('$uploadfile','".$_POST['Result']."')>";
    echo "<br>下面是文件上传的一些信息:

    <br>原文件名:".$_FILES['upfile']['name'] .

    "<br>类型:" .$_FILES['upfile']['type'] .

    "<br>临时文件名:".$_FILES['upfile']['tmp_name'].

    "<br>文件大小:".$_FILES['upfile']['size'] .

    "<br>错误代码:".$_FILES['upfile']['error'];
    }


    ?>
    <script language="JavaScript">
    <!--
    function CopyPath(FilePath,FileSize)
    {
    // var str=location.toString()
    // var Result=((((str.split('?'))[1]).split('='))[1]);
    //window.opener.form1.FileSize.focus();
    window.opener.document.form1.<?php echo $_GET["Result"];?>.value=FilePath;
    //if (Result == "FileUrl")
    // {
    // window.opener.document.form1.FileSize.value=FileSize;
    // }
    window.opener=null;
    window.close();
    }
    //-->
    </script>
  • 相关阅读:
    python之路day10命名空间和作用域、函数嵌套,作用域链、闭包
    20200719 千锤百炼软工人第十四天
    20200720 千锤百炼软工人第十五 天
    JavaScript中基本数据类型和引用数据类型的区别
    js 经纬度坐标格式化 度分秒转度 度转度分秒
    export ,export default 和 import 区别 以及用法
    10月28日学习日志
    10月20日学习日志
    10月29日学习日志
    10月27日学习日志
  • 原文地址:https://www.cnblogs.com/wanghaoning/p/14915529.html
Copyright © 2011-2022 走看看