Hi Guys,
I have a web site that I need to list/view the files stored in a directory. I wont to do this using PHP but I am not sure how to do it. Can someone write or give me some code that will do this for me. If Small images for Filesand Folders can be added that would help me alot.
The Directory that stores the files that I wont to list is called 'Files'.
It is located in my root directory example.com/files/.
Please can some one help me
Cheers
Thomas Park
PHP File Browser/List
Moderator: General Moderators
-
thomaspark
- Forum Newbie
- Posts: 3
- Joined: Sat Jun 06, 2009 4:36 pm
Re: PHP File Browser/List
Hi There,
I have this pace of code know.
I wont to add icons to the side of the Files and Folders.
Can someone show me how to do this?
I have this pace of code know.
Code: Select all
<?php
//Directory
$handle=opendir("./files");
$projectContents = '';
while ($file = readdir($handle))
{
$projectContents .= '<li><a href="files/'.$file.'">'.$file.'</a></li>';
}
closedir($handle);
//end Dirctory
$pageContents = <<< EOPAGE
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html lang="en" xml:lang="en">
<head>
<title>Folders</title>
<meta http-equiv="Content-Type" content="txt/html; charset=utf-8" />
<!-- Style for Page -->
<style type="text/css">
ul.aliases, ul.projects, ul.tools {
list-style: none;
line-height: 24px;
}
ul.aliases a, ul.projects a, ul.tools a {
padding-left: 22px;
background: url(test1.php?img=pngFolder) 0 100% no-repeat;
}
</style>
<link rel="shortcut icon" href="test1.php?img=favicon" type="image/ico" />
</head>
<!-- Main Body -->
<body>
<font face="Arial">
<h2>Files</h2>
<ul class="projects">
$projectContents
</ul>
</font>
</body>
</html>
EOPAGE;
echo $pageContents;
?>
Can someone show me how to do this?
Last edited by Benjamin on Mon Jun 08, 2009 1:49 pm, edited 1 time in total.
Reason: Changed code type from text to php.
Reason: Changed code type from text to php.
-
thomaspark
- Forum Newbie
- Posts: 3
- Joined: Sat Jun 06, 2009 4:36 pm
Re: PHP File Browser/List
Sorry jus a little bit more.
I also don't wont the page to show the 'index.php' file.
Can someone edit my code to do both of these things.
Cheers
Thomas
I also don't wont the page to show the 'index.php' file.
Can someone edit my code to do both of these things.
Cheers
Thomas