This PHP Code snippet lists all files in a folder and hyperlinks them accordingly. Very clean, easy to use function. Just cut and paste.
<?php
/*
This is a simple function to list all files in a specific folder on your web server.
Function require path to the folder to be passed on to it.
It then echoes the Hyperlinked list of files.
*/
function listFilesInDirectory($folder)
{
// Function gets name of folder
if(is_dir($folder))
{ // Works only if the folder is found
if($handle = opendir($folder))
{ // Now it has successfully opened the folder to get its content.
while(($file = readdir($handle)) !== false)
{ // Now we look through all file and folder names
if($file != "." && $file != ".." && $file != "Thumbs.db")
{ // Here we ignore some file names like [.] [..] and Thumbs.db files/folders
// Now we print the hyperlinked list of files/folders
// <a> tag is for links
// <br> tag is for line feeds.
echo '<a target="_blank" href="'.$folder.$file.'">'.$file.'</a><br>'."\n";
}
}
closedir($handle); // This does some housekeeping
}
}
} // End of List Files In directory function
// Let Us call the function and see how it goes!
listFilesInDirectory("path/to/folder/inside/script");
?>
I want folder to gallery PHP Script. I will have all images in one folder. And PHP Script should show those images on a web page. It should page it will 25 images per page.
Price $25 Order Now
I need PHP folder listing script which shows list of sub-folders and clicking on sub-folder should show sub-folder in it.
Price $15 Order Now
I want PHP code to show folder permissions.
Price $5 Order Now
I want PHP Script to rename all files in a folder by appending certain text string to file names.
Price $5 Order Now
PHP Script to Generate Random Password. You can set the list of characters that you want to be used in...
It is a very nice PHP time ago function. You gave pass any date to it and it will tell...
PHP Script to create URL from string. It retails only URL Safe characters in the strings. So, now easily create...
This is a simple function written in PHP to generate keywords from any text. Just pass any free text to...
This is a simple PHP function to parse text provided and automatically hyperlink the links in the text.
This PHP function extracts all numbers from a String and prints them as a comma separated list of numbers. Ready...
This PHP Code snippet lists all files in a folder and hyperlinks them accordingly. Very clean, easy to use function....
PHP Script to extract all links from a web page. This PHP Snippet reads the contents of a web page...