• php中图片文件的导入,上传与下载


    ---------------------------------------------图片的导入-------------------------------------------------------------------
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>图片的上传与下载</title> </head> <body> <form action="donpload.php" method="post" enctype="multipart/form-data"> 上传图片: <input type="file" name="pic" /> <input type="submit" value="上传" /> </form> <table width="500" border="1"> <tr> <th>序号</th> <th>图片</th> <th>添加时间</th> <th>操作</th> </tr> <?php //打开目录 $dir=opendir("./images"); //遍历目录 $i=0; while($f=readdir($dir)){ if($f!="." &&$f!=".."){ $i++; echo"<tr>"; echo"<td>{$i}</td>"; echo"<td><img src='./images/{$f}' width='100' height='100'/></td>"; echo"<td>".date("Y-m-d",filectime("./images/".$f))."</td>"; echo"<td>查看,下载</td>"; echo"</tr>"; } } //3.关闭目录 closedir($dir); ?> </table> </body> </html>

    获取上传文件的上传信息

    <?php
        session_start();
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>解析文件上传</title>
    </head>
    <body> 
           <center>
           <h3>解析文件上传</h3> 
           <?php
               if($_SESSION['time']==$_POST[time]){
                   if(isset($_POST[sub])){
                       $file=$_FILES[name];
                              echo "上传文件的路径名称:".$file['tmp_name']."<br>";
                              echo "上传文件的名称:".$file['name']."<br>";
                              echo "上传文件的类型:".$file['type']."<br>";
                              echo "上传文件的错误信息:".$file['error']."<br>";
                              echo "上传文件的大小:".$file['size'];
                       }
                   }
                  $time=mt_rand(0,10000);
                  $_SESSION['time']=$time;
           ?>
           <form action="3.php" method="post" enctype="multipart/form-data">
           <input type="file" name="name" />
           <input type="hidden" name="time" value="<?php echo $time;?>">
           <input type="submit" name="sub" value="上传" />
           </form>
           </center>
    </body>
    </html>

                                                                  

  • 相关阅读:
    CSS自定义滚动条样式
    利用jquery和css打造个性化的单选框和复选框
    jQuery cookie 购物车及其实现
    php遍历数组 list foreach each方法总结
    css秘籍:复选框与文字对齐的问题
    Spring项目中的classpath路径
    idea快捷键盘Ctrl+H查看类的结构
    java中的反射机制(一)
    观察者设计模式
    Application context not configured for this file
  • 原文地址:https://www.cnblogs.com/kangshuai/p/4859622.html
Copyright © 2020-2023  润新知