I am trying to develop an ftp-type of site. I would like an administrator to be able to upload a file to a specified directory from a back end administration area.
On the front end I would like a user to be able to come to the website that will display the file or directory name, the file type (dir, jpg, pdf, etc...), the file or directory size, the date the file was created and a short description of the file. The user can click on the file to download it or click on a directory name that will take them to another page that displays all of the files or directories within that directory that are clickable to either open or download and so forth.
I have used the php code below for the front end. It is not complete, but it does show the file or directory name and allows the user to click on it.
Does anyone have any thoughts on how to provide the rest of the functionality. Should I get MySQL involved?
Thanks in advance!
<?php
//define the path as relative
$path = "files";
//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");
//running the while loop
while ($file = readdir($dir_handle))
{
if($file!="." && $file!="..")
echo "<tr>
<td bgcolor=\"#DDDDDD\" width=\"33\" align=\"center\">
<a href=\"$file/index.php\">
<img border=\"0\" src=\"images/Folder.gif\" width=\"16\" height=\"16\"></a></td>
<td bgcolor=\"#DDDDDD\" width=\"139\" align=\"center\"><font face=\"Arial\" size=\"2\">
<a href=\"$file/index.php\" style=\"text-decoration: none\">$file</a></font></td>
<td bgcolor=\"#DDDDDD\" width=\"84\" align=\"center\"><font face=\"Arial\" size=\"2\"><DIR></font></td>
<td bgcolor=\"#DDDDDD\" width=\"84\" align=\"center\"><font face=\"Arial\" size=\"2\">
10 Items</font></td>
<td bgcolor=\"#DDDDDD\" width=\"85\" align=\"center\"><font face=\"Arial\" size=\"2\">11/24/06</font></td>
<td bgcolor=\"#DDDDDD\" width=\"177\" align=\"center\"> </td>
</tr>";
}
//closing the directory
closedir($dir_handle);
?>