[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 108
  • Last Modified:

How do I create an html list from list of files?

I would like to create an html web page which looks in a specific directory and then lists the names of the files, as a link, to the files in that directory.  This is for an intranet purpose.

ie. Folder1 has 10 files, all pdf files with various names.  I want to create a web page for the intranet, which lists all those 10 files, and if you click on the name of the file then it will open the pdf files.
0
100questions
Asked:
100questions
  • 2
1 Solution
 
Tim PhillipsCommented:
This software looks like it will do what you want:  http://www.dimin.net/software/HTMLDirCreate/
0
 
MurfurFull Stack DeveloperCommented:
Here's one I wrote way back in 2008... it is very simple but effective and each file or directory is a link that you can click on to open. I use it as the index for my WIP directory so any file or mini-app can be opened with a single click and without having to remember all the paths to type in the browser URL.

It is PHP but the same principle applies for other languages
<?php
echo"<html>";
echo"<head>";
echo"<title>File List</title>";
echo"<style type=\"text/css\">";
echo"<!--";
echo"body,td,th {";
echo"font-family: Verdana, Arial, Helvetica, sans-serif;";
echo"font-size: 11px;";
echo"color: #333333;";
echo"}";
echo"-->";
echo"</style>";
echo"</head>";
echo"<body>";
echo "<h2>Files/Directories</h2>";
echo "This folder contains:<br /><br />";

$dir = opendir(getcwd());
while (false !== ($file = readdir($dir)))
{
	if(true == is_dir($file)&&$file!=="."&&$file!==".."&&$file!=="phpmyadmin"&&$file!=="signoff"&&$file!=="internal")
	{
	echo "<li>&lt;dir&gt;&nbsp;<a href=\"$file\">$file</a></li>";
	}
}

$dir = opendir(getcwd());
while (false !== ($file = readdir($dir)))
{
	if(false == is_dir($file)&&$file!=="."&&$file!==".."&&$file!==".htaccess"&&$file!==".htpasswd"&&$file!==".bash_history"&&$file!=="index.php"&&$file!=="index.php.bak")
	{
		echo "<li>file&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"$file\">$file</a> ".round(filesize($file)/1000)."kb</li>";
	}
}
?>

Open in new window

0
 
100questionsAuthor Commented:
One can use ARCLab Dir2 HTML software.
0
 
100questionsAuthor Commented:
This works.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now