0

I am trying to read all files from a directory and store it in an array.But the file which contains this code is on www.xyz.com domain and i want to check files exist on https://www.test.com/prod_images/.But glob is returning empty array.Why is it returning empty array ?

foreach (glob('https://www.test.com/prod_images/*', GLOB_ONLYDIR) as $dir) {
    $dirname = basename($dir);
    $items[] = $dirname;
}
print_r($items);
piya
  • 205
  • 1
  • 6
  • 15
  • 1
    Thats not possible. – tkausl Jun 25 '16 at 06:32
  • So how can i implement this ? and can you please let me know why it is not possible ?@tkausl – piya Jun 25 '16 at 06:35
  • You can't. It simply isn't possible, the HTTP protocol does not implement anything like this, and if it would, it would be a big security risk and servers probably wouldn't obey those requests. – tkausl Jun 25 '16 at 06:38
  • 1
    Why is it not possible? Because the domain in question determines whether a complete folder can be shown or not, and it is typically disallowed for security reasons. But access on that server isn't a filesystem function either; when it is allowed, its handled by the webserver, not by the filesystem on that server – Mark Baker Jun 25 '16 at 06:38
  • 1
    I think this may help for you. your ans is here.Check this ans for get image from other domain. http://stackoverflow.com/questions/17464345/get-file-contents-of-a-domain-in-another-domain-in-the-same-server – Nikhil Vaghela Jun 25 '16 at 06:42
  • Thanks..!!! it worked for me @ Nikhil Vaghla – piya Jun 25 '16 at 11:41

0 Answers0