Glob not giving me any results

前端 未结 2 1075
我寻月下人不归
我寻月下人不归 2020-12-19 03:32

I\'m trying to use PHP\'s Glob to get a list of files based on a wildcard, namely the extension.

$images = glob(\'/content/big/\'.$item[\'id\'].\'.{jpg,jpeg,         


        
2条回答
  •  自闭症患者
    2020-12-19 03:42

    glob only works with paths on the server's file system, not URLs.

    http://www.website.com/content/big/ may really be /var/www/site/content/big on the server, and that's the path you need to use.

    Staring a path with a / makes glob look in your root for that folder, and I'm assuming there is no folder called /content/big/ on your server.

    Try it like this (using a relative path from the server root):

    $images = glob('content/big/'.$item['id'].'.{jpg,jpeg,png,gif}', GLOB_BRACE);
    

    Or use an absolute path:

    $images = glob('/var/www/site/content/big/'.$item['id'].'.{jpg,jpeg,png,gif}', GLOB_BRACE);
    

提交回复
热议问题