Jump to content

Php File Listing... For An Ftp Folder


biketrialler

Recommended Posts

heya, just looking for a simple script...

on my webspace, i want it to list the files when i go to www.bennifer.co.uk rather than just say access denied like it does right now. what is a simple php file i can put in the root of that folder that will then just list out what is in it?

i did google, but didnt find what i was after - its hard to know what to search for.

thanks to helpers!

ben

Link to comment
Share on other sites

The one i use is the following

<?

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Image View / Upload Section ///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

echo "<h1>".$title." - News/Product Images</h1>";
echo "<div id=\"bigbox\">";

$list_ignore = array ('.','..','listing.php');
$handle=opendir(".");
$dirs=array();
$files=array();
$i = 0;
while (false !== ($file = readdir($handle))) {
if (!in_array($file,$list_ignore)) {
if(!eregi("([.]bak)",$file)) { // ignore backup files
if(is_dir($file)) {
$dirs[]=$file;
} else {
$files[]=$file;
}
$i++;
}
}
}
closedir($handle);

$tab=array_merge($dirs,$files);
if ($i) {
foreach ($tab as $rep) {
if(eregi("[.]doc", $rep)) {
$ext="txt";
} elseif(eregi("([.]zip)|([.]rar)", $rep)) {
$ext="zip";
} elseif(eregi("([.]gif)|([.]jpg)|([.]jpeg)|([.]png)", $rep)) {
$ext="image";
} elseif(eregi("([.]html)|([.]htm)", $rep)) {
$ext="html";
} elseif(eregi("[.]php", $rep)) {
$ext="php";
} elseif($rep[folder]==true) {
$ext="folder";
} else {
$ext="unknown";
}
echo ('<a href="'.$rep.'"><img src="images/'.$ext.'.gif" border="0" /> '.$rep.'</a><br />');
}
} else {
echo "No files";
}

echo "</div>";

?>[/code]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...