Printing Directory Script

Printing Directory Script is used to listing files from directory .

Demo :

Text   File Name :
 File Type

Example :

In the above demo scripts textarea is used to write content for file and file name text box is used to give to file name for file and file type is used to select file type for file.For example if you create file that will be displayed file below of demo.

Code :

Following code is use to Printing Directory script if you need code to copy and use to your website.

function printTree($dir, $depth=0)
  if (!is_dir($dir)) { die("Argument is not a directory!"); }
  $dh = opendir($dir) or die ("Cannot open directory");
  while (($file = readdir($dh)) !== false) {
  if ($file != "." && $file != "..") {
  if (is_dir("$dir/$file")) {
  echo str_repeat(" ", $depth) . " [$file]\n";
  printTree("$dir/$file", ($depth+1));
  } else {
  echo str_repeat(" ", $depth) . " $file\n";
  printTree('Path Name');

In the above printTree() function is used to list files or any date from folder (directory). which files three predefined function has been used that are is_dir(),opendir(),str_repeat () and readdir().

Free Download Script :

If you need Printing Directory Script click and download from following link.