jch02140 Posted September 13, 2010 Share Posted September 13, 2010 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 More sharing options...
chintansshah Posted September 13, 2010 Share Posted September 13, 2010 opendir is not work for http, it works with ftp only. You should find any alternative solution. 1. CURL 2. Fsocket Please let me know if you are not aware of about two terms. Link to comment https://forums.phpfreaks.com/topic/213274-simple-remote-image-display-script-help/#findComment-1110518 Share on other sites More sharing options...
jch02140 Posted September 14, 2010 Author Share Posted September 14, 2010 I am not sure about CURL... but I read a little on foscket.. but I am not sure how to implement it... Link to comment https://forums.phpfreaks.com/topic/213274-simple-remote-image-display-script-help/#findComment-1111063 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.