Sort File Script

Sort file script is used to sort an files are size,date and name typically and also you can filter through Sort By Name and Sort By Date and Size.

Demo :



Text   File Name :
   
 File Type
 
  Sort By Name    Sort By Date,Size    

Example :

Just type content or details at text area and type file name at text box and also select file type at select box and click write button , now will be created files and default sorted are sort By name and sort by date,size.

Code :

Following code is use to Sort File Script core if you need code to copy and use to your website.


<?php
$dir = "";
if (!is_dir($dir))
{
  die("Argument '$dir' is not a directory!");
}
$dh = opendir($dir) or die ("Cannot open directory '$dir'!");
while (($file = readdir($dh)) !== false)
{
  if ($file != "." && $file != "..")
  {
    $fileList[] = array("name" => $file, "size" => filesize("$dir/$file"), "date" => filemtime("$dir/$file"));
  }
}
closedir($dh);
foreach ($fileList as $key=>$value)
{   $name[$key] = $value['name'];
  $size[$key] = $value['size'];
  $date[$key] = $value['date'];
}
array_multisort($name, $fileList);
print_r($fileList);
?>

In the above code opendir() function is used to will open files from directory and readdir() function is use to will read files from directory. $name[$key] is use to array name are stored place and $size[$key] is used to array size are stored place and $date[$key]is used to array date value are stored place.array_multisort() function is used to sort by name,size and date.

Free Download Script :

If you need Sort File Script click and download from following link.

Download




Content