PHP头条
热点:

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=gb2312" />
<title>显示文件夹内文件</title>
</head>

<body>
<?php
 $sort_file=array();
 $filefj=array();
 define('FILEPATH','../filehandle/uploadfile/');
 $sortlist=trim($_GET["sort"]);
 $dir=opendir(FILEPATH);
 echo'文件上传位置:'.FILEPATH.'<br/>';
 echo'文件列表:'.'<ul>';
 
 if($sortlist == 'filetype'){
  while (($file=readdir($dir))!== false) {
   if ($file != "." && $file != "..") {
    $file=basename($file);
    $sort_file[]=$file;
         }
     }
     
     foreach ($sort_file as $key=>$var) {
   $filefj[]=explode('.',$var);
  }
    
        usort($filefj,'compare');
       
        foreach ($filefj as $key=>$val){
         $combinationfile=implode('.',$val);
         echo '<li>'. $combinationfile.' </li>';
        }      
 }else{
  while (($file=readdir($dir))!== false) {
   if ($file != "." && $file != "..") {
    $file=basename($file);
             echo '<li>'.$file.$file_size.' </li>';
         }
     }
 }
    echo '</ul>';
 closedir($dir);
 echo'</br>';
 echo'<a href="index.php?sort=filetype">按文件类型排序</a>&nbsp;&nbsp;&nbsp;<a href="index.php">按正常文件排序</a>&nbsp;&nbsp;&nbsp;<a href="upfile.html">继续上传文件</a>';
 
 function compare($x,$y){
   if($x[1]==$y[1])
    return 0;
   else if ($x[1]<$y[1])
    return -1;
   else return 1;
 }
?>

</body>
</html>
文件效果就不说了,自己试一一就知道了.

www.phpzy.comtrue/php/25475.htmlTechArticlephp多文件上传代码三 !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; cha...

相关文章

    暂无相关文章

PHP之友评论

今天推荐