Jump to content

Simple remote image display script help


jch02140

Recommended Posts

Hi,

 

I am planning to display remote images with the following code but it seems to return errors.

 

<?php
$image_dir = 'http://www.domain.com/images/' ;
$dir_handle = opendir( $image_dir );
$count = 0 ;
$display = '' ;
while( $filename = readdir($dir_handle)){
if( preg_match( '/$[a-z0-9]{4}_th\.jpg$/' , $filename ) ){
    $display .= " <img src='$image_dir$filename' /> " ;
    $count++ ;
    if( $count % 10 == 0 ){
       $count=0;
       $display .= "<br />";
    }
}
}
closedir( $dir_handle );
echo $display ;
?>

 

I am thinking might be the $image_dir cannot use address format....

 

Errors is as follow

 

Warning: opendir(http://www.foo.com/images/) [function.opendir]: failed to open dir: not implemented in /home/jch02140/public_html/test.php on line 3

 

Warning: readdir(): supplied argument is not a valid Directory resource in /home/jch02140/public_html/test.php on line 6

 

Warning: closedir(): supplied argument is not a valid Directory resource in /home/jch02140/public_html/test.php on line 16

Link to comment
https://forums.phpfreaks.com/topic/213274-simple-remote-image-display-script-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.