tiehao 发表于 2013-2-7 02:02:23

文件上传下载

文件上传
<!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=gb2312" />   <title>文件上传</title>   </head>   <body>   <form enctype="multipart/form-data" action="upload.php" method="post">   <input name="upfile" type="file"><br>   <input name="submit" value="submit">   </form>   </body>   </html>   <?php //upload.php   $uploadfile = "upfiles/".$_FILES['upfile']['name'];//上传后文件的路径和名字   move_upload_file($_FILES['upfile']['tmp_name'],$uploadfile);   print_r($_FILES);   ?>   //文件下载   <?php    $dir = "Download/";   $dir_res = opendir($dir);   echo "<h1>文件下载</h1>";   while($filen = readdir($dir_res)){       if($filen!="."and $filen!="..")       echo "<a herf = '".$dir.$filen."'>".$filen."</a><br>";   }   closedir($dir_res);   ?> 
 
页: [1]
查看完整版本: 文件上传下载