get all the images from a folder in php

前端 未结 9 2241
南方客
南方客 2020-12-04 14:37

I am using WordPress. I have an image folder like mytheme/images/myimages.

I want to retrieve all the images name from the folder myimages<

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 15:14

    you can do it simply with PHP opendir function.

    example:

    $handle = opendir(dirname(realpath(__FILE__)).'/pictures/');
    while($file = readdir($handle)){
      if($file !== '.' && $file !== '..'){
        echo '';
      }
    }
    

提交回复
热议问题