---------------------------------------------图片的导入-------------------------------------------------------------------
<!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>