Search code examples
phpfile-ioglob

Copy all images from remote url in PHP


I need to copy all images from remote url. GLOB is not working. For eg: URL = http://www.example.com/media/k2/galleries/124 Here 124 is directory name. I need to copy all images from that directory using php code. How to do that?


Solution

  • unless you've got some fancy filesystem setup, that url is of course http protocol. GLOB is for (local) filesystem operations. Use curl or whatever builtin is used in php for http. btw you will need to know all the urls to download. Just because 124 happens to be a directory on a webserver doesn't matter...there's no DIR command to list all the files (urls actually) on the webserver.