how to read files saved on the server using php and make a call to that php page using ajax to display the list of files

后端 未结 1 1108
被撕碎了的回忆
被撕碎了的回忆 2021-01-25 20:50

how to rad the names of all files saved in the folder on the server using php. and then make a call to that php page using ajax to display that list of files

1条回答
  •  醉话见心
    2021-01-25 21:08

    This is the code to display file list:

    $dir   = '/tmp'; // your directory path
    $files = scandir($dir);
    
    foreach ($files as $file)
    {
      if (is_file($file))
      {
        echo $file . '
    '; } }

    This is the HTML/JavaScript to display the file list (if you use jQuery which is highly advised):

    
    
    
        
        File list
    
    
        

    0 讨论(0)
提交回复
热议问题