list files in a directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Users, I need some help.

 

I got some directories on a web server, these I called with PHP to be
displayed on an HTML page. But I do not get them sorted properly. I want
them to be sorted by name and not by size. Could some one please shed some
light on this.

 

Thanks

 

 

============================================================================
===========

 

<?php

 

function disfile($dir, $file, $num, $status)

{

            $filelength = strlen($file);

            $disfile = substr($file, 0, ($filelength -3));

            if($status == 'true')

            {

                        $file_link .= "<INPUT TYPE=RADIO NAME=\"file_name\"
VALUE=\"$dir$file\"> $disfile<br>";

            }else{

                        $file_link .= "<li> <a href=\" $dir$file\"
target=\"_blank\">" . $disfile . "</a></li>";

                        //<font size=1>($filesizefile $term)</font><br>";

            }

            return $file_link;

}

 

function download($dir,$ms)

{

            if (isset($_GET['download']))

            {

                        header("Content-Type: octet/stream");

                        header("Content-Disposition: attachment; filename="
. basename($_GET['download']));

                        //echo file_get_contents($_GET['download']);

            } else {

                        if ($open = opendir($dir))

                        {

                                    $num = 0;

                                    while (false !== ($file =
readdir($open)))

                                    {

                                                if ($file != "." && $file !=
"..")

                                                {

                                                            //echo
"$file\n";

                                    

                                                            if (!is_dir($dir
. $file))

                                                            {

                                                                        $num
++;                                                                      

 
$folder_files .= disfile($dir,$file,$num,$ms);

                                                            }

                                                }

                                    }                                   

                        }

                        closedir($open);

            }

 

            return $folder_files;

}

 

 

 

?>

 

 

============================================================================
===========


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux