?
Solved

list files to php

Posted on 2003-03-08
8
Medium Priority
?
218 Views
Last Modified: 2006-11-17
How can I get "list.php" to list the files from a folder. i.e. d:\documents\?
I just want a simple list so that my students can view the projects archieve etc..

Please help!
0
Comment
Question by:Virik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 6

Expert Comment

by:carchitect
ID: 8096878
<?
$d = dir("password"); ///directory path
echo "Handle: ".$d->handle."<br>\n";
echo "Path: ".$d->path."<br>\n";
while (false !== ($entry = $d->read())) {
    echo $entry."<br>\n";
}
$d->close();
?>


regards
0
 

Author Comment

by:Virik
ID: 8097798
Thanks!

But, I must be stupid or something =)
Where in the code do I type "D:\documents", and what
else must I change?
0
 
LVL 6

Accepted Solution

by:
carchitect earned 1000 total points
ID: 8098722
hi i have written to change directory path sir...

<?
$d = dir("D:\documents"); ///directory path
echo "Handle: ".$d->handle."<br>\n";
echo "Path: ".$d->path."<br>\n";
while (false !== ($entry = $d->read())) {
   echo $entry."<br>\n";
}
$d->close();
?>



0
7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

 
LVL 15

Expert Comment

by:VGR
ID: 8101441
what a C style !!! :D :D

Solution 1 : (whatever, not sorted, or sorted by default by the OS)
$d = dir("./s/");
while($entry=$d->read()) {
  if (($entry<>'.') and ($entry<>'..') and ($entry<>'')) {
    // do your stuff on the file of name = $entry
  } // if affichage
} // while
$d->close();

Solution 2 : (Windows, sorted by alphabetic name)
$directory2=str_replace('/','\\',$directory);
$d = @popen ("dir /ON /B $directory2", "r"); //
while (!feof ($d)) {
  $buffer = fgets($d, 4096);
  $entry=chop($buffer);
  if (($entry<>'.') and ($entry<>'..') and ($entry<>'')) {
    //do your stuff on file $entry
  } // if affichage
} // while
$toto=@pclose($d);
0
 

Expert Comment

by:hexabr
ID: 8159050
a simple

$vars = ´ls *.ext´ wouldnt sufice?
0
 
LVL 15

Expert Comment

by:VGR
ID: 8159255
exec("ls ..."); yes, a simple "ls" no ;-)

dir() or popen("dir") (windows) are the same as exec("dir")
0
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 11934158
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    Accept: carchitect {http:#8098722}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

snoyes_jw
EE Cleanup Volunteer
0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question