|
Hello,
Below is the code I am using as an index.php file inside a file folder that I want web guests to be able to view the contents of. Everything is working great except that the files are not in the correct alphanumeric order, so I think I need to add a piece of code to tell it to do so, but being a novice at php, I am unsure what to add. (I do have the u/s/e/Username field correct for my file name, so no worries there. Like I said, everything works except sort order.) Could someone look at my code below and tell me what I need to get it to sort my files in ascending alphanumeric order by their file name? What I do is upload all the Word documents to the server through Word and then instead of having to create a link for each document, the files appear right in the folder for viewing on the Internet. Please help! Thanks! :-)
<?
/**
* Change the path to your folder.
*
* This must be the full path from the root of your
* web space. If you're not sure what it is, ask your host.
*
* Name this file index.php and place in the directory.
*/
// Define the full path to your folder from root
$path = "/home/content/U/s/e/Username/html/Folder/2000/";
// Open the folder
$dir_handle = @opendir($path) or die("Unable to open $path");
// Loop through the files
while ($file = readdir($dir_handle)) {
if($file == "." || $file == ".." || $file == "index.php" )
continue;
echo "<a href=\"$file\">$file</a><br />";
}
// Close
closedir($dir_handle);
?>
|