-4

I'm trying to write some php to make an image slideshow from a file on a server. When I try to opendir it gives me the error in the title

$images = glob('*.{jpg,jpeg,png,gif}', GLOB_BRACE);
$count = count($images);
$var_count = $count + 1;

$arr_img = Array();
$handle = opendir('http://dev2.matrix.msu.edu/~matrix.training/Holmberg_Dane');
while (false !== ($file = readdir($handle))) {
 if ($file != "." && $file != "..") {
    $arr_img[] = $file;
 }
}

1 Answers1

3

You can't call opendir() on an HTTP address. HTTP doesn't have the concept of "directories" (unless you count WebDAV).

Chris
  • 5,571
  • 2
  • 20
  • 32
  • So how do I reach the directory that I need from the server? – daneholmberg May 26 '16 at 17:46
  • @daneholmberg Either make the server read the directory itself and return the contents in a machine-readable format like JSON, or (assuming your server is actually set up to automatically produce an Apache directory listing) parse the HTML directory listing outputted by the server. – Chris May 26 '16 at 17:52