Read in all the files in a particular directory displays the file names in a html list

Rup Gautam

Reading all the files from a particular directory and displays the files names/Links in a html list. (file ext: .pdf) I'm looking for output something like:

  • filename 1
  • filename 2
  • filename 3

My code:

<ul> 
    <?php 
      $dir = '/my_directory_location'; 
      $files = scandir($dir); 
      foreach ($files as $ind_file) { 
      ?> <li> <a href="<?php echo $dir."/".$ind_file;?>"><?php echo $ind_file;?></li> 
      <?php } ?> 
</ul>

Thanks in Advance

Shankar Damodaran

You probably need the glob() in PHP

<?php
foreach (glob("*.pdf") as $filename) {
    echo "$filename<br>";
}

OUTPUT :

resume1.pdf
resume4.pdf
resume5.pdf

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How do you get a list of the names of all files present in a directory in Node.js?

From Java

bash: use list of file names to concatenate matching files across directories and save all files in new directory

From Dev

Inno Setup: List all file names in an directory

From Dev

Read all properties files in a directory

From Dev

read all files in a directory, then add the content of each file into a listbox?

From Dev

Display and read all files in directory

From Dev

Include all javascript files in a directory to a html file in angularjs? with grunt?

From Dev

SFTP Read all files in directory

From Dev

Delete particular files in all subdirectories of a directory in linux

From Dev

List file information in a text file for all the files in a directory

From Dev

R read all files in a directory

From Dev

Bash - Check directory for files against list of partial file names

From Dev

grep all .java files in a directory for a particular string

From Dev

Bash - Check directory for files against list of partial file names

From Dev

How to delete all files in particular folder present in current directory sub-folders excluding a certain file?

From Dev

Take a file directory consisting of files and write all files to a folder with different names in another folder

From Dev

How to list packages with files in a particular directory?

From Dev

Read first file in a list of files within a directory

From Dev

Global alias for all files in a directory, by their file names (extensions, if available will be omitted)

From Dev

How to recursively list all files of desired file type in a specified directory?

From Dev

How to list all files in named directory, file type included?

From Dev

Using a list of all file names, output missing files names if not contained in folder (batch script)

From Dev

Read files in a directory matching a particular pattern through MapReduce and output the names of the individual files

From Dev

List names of files in FTP directory and its subdirectories

From Dev

How to create a log file that displays the names of files and the contents of it

From Dev

Batch Files: List file names and folder names

From Dev

SAS list all file names issue (authorization to some files but not all)

From Dev

Read unknown file names from directory

From Dev

Copy all files from subdirectories and subsubdirectories to main directory with modifying file names by adding prefix of all parent directories

Related Related

  1. 1

    How do you get a list of the names of all files present in a directory in Node.js?

  2. 2

    bash: use list of file names to concatenate matching files across directories and save all files in new directory

  3. 3

    Inno Setup: List all file names in an directory

  4. 4

    Read all properties files in a directory

  5. 5

    read all files in a directory, then add the content of each file into a listbox?

  6. 6

    Display and read all files in directory

  7. 7

    Include all javascript files in a directory to a html file in angularjs? with grunt?

  8. 8

    SFTP Read all files in directory

  9. 9

    Delete particular files in all subdirectories of a directory in linux

  10. 10

    List file information in a text file for all the files in a directory

  11. 11

    R read all files in a directory

  12. 12

    Bash - Check directory for files against list of partial file names

  13. 13

    grep all .java files in a directory for a particular string

  14. 14

    Bash - Check directory for files against list of partial file names

  15. 15

    How to delete all files in particular folder present in current directory sub-folders excluding a certain file?

  16. 16

    Take a file directory consisting of files and write all files to a folder with different names in another folder

  17. 17

    How to list packages with files in a particular directory?

  18. 18

    Read first file in a list of files within a directory

  19. 19

    Global alias for all files in a directory, by their file names (extensions, if available will be omitted)

  20. 20

    How to recursively list all files of desired file type in a specified directory?

  21. 21

    How to list all files in named directory, file type included?

  22. 22

    Using a list of all file names, output missing files names if not contained in folder (batch script)

  23. 23

    Read files in a directory matching a particular pattern through MapReduce and output the names of the individual files

  24. 24

    List names of files in FTP directory and its subdirectories

  25. 25

    How to create a log file that displays the names of files and the contents of it

  26. 26

    Batch Files: List file names and folder names

  27. 27

    SAS list all file names issue (authorization to some files but not all)

  28. 28

    Read unknown file names from directory

  29. 29

    Copy all files from subdirectories and subsubdirectories to main directory with modifying file names by adding prefix of all parent directories

HotTag

Archive