hi guys,
i have folder containing all pdf files i want to display their name on php page and when i click any of it, it will open so kindly help me in this regards how can i do this,
it is very urgent for me
waiting fro your replies...
how to select all files from folder
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: how to select all files from folder
Probably glob() would be the easiest way, but there are several other ways to read directories.
http://www.php.net/manual/en/function.glob.php
http://www.php.net/manual/en/function.glob.php
(#10850)
Re: how to select all files from folder
thanks for reply i am using that code but their is problem in opening the pdf file
//echo "<select name=\"file\">\n";
foreach (new DirectoryIterator('D:/paper_less/finance/Investment Consultative Group.') as $file) {
// if the file is not this file, and does not start with a '.' or '..',
// then store it for later display
if ( (!$file->isDot()) && ($file->getFilename() != basename($_SERVER['PHP_SELF'])) ) {
// echo "<option>";
// if the element is a directory add to the file name "(Dir)"
?>
<a href="file:///D://paper_less/finance/Investment%20Consultative%20Group/<?php echo ($file->isDir()) ? "(Dir) ".$file->getFilename() : $file->getFilename(); ?>"><?php echo ($file->isDir()) ? "(Dir) ".$file->getFilename() : $file->getFilename(); ?> </a> <?php
// echo "</option>\n";
}
}
//echo "<select name=\"file\">\n";
foreach (new DirectoryIterator('D:/paper_less/finance/Investment Consultative Group.') as $file) {
// if the file is not this file, and does not start with a '.' or '..',
// then store it for later display
if ( (!$file->isDot()) && ($file->getFilename() != basename($_SERVER['PHP_SELF'])) ) {
// echo "<option>";
// if the element is a directory add to the file name "(Dir)"
?>
<a href="file:///D://paper_less/finance/Investment%20Consultative%20Group/<?php echo ($file->isDir()) ? "(Dir) ".$file->getFilename() : $file->getFilename(); ?>"><?php echo ($file->isDir()) ? "(Dir) ".$file->getFilename() : $file->getFilename(); ?> </a> <?php
// echo "</option>\n";
}
}