2013-01-09 72 views
0

我有以下顯示圖像從外部文件夾中的文件夾(幻燈片)/ URL

<?php 
$directory = 'images/slideshow';  
try {  
    // Styling for images 
    echo '<div id="myslides">'; 
    foreach (new DirectoryIterator($directory) as $item) {    
     if ($item->isFile()) { 
      $path = $directory . '/' . $item; 
      echo '<img src="' . $path . '"/>'; 
     } 
    } 
    echo '</div>'; 
} 
catch(Exception $e) { 
    echo 'No images found for this slideshow.<br />'; 
} 
?> 

代碼從這個主題複製: Display Images From A Folder (slideshow)

我想知道,如果可能的從外部加載圖像,或從URL的特定目錄加載圖像?提前致謝。

回答

0

這是可能的,但你需要知道每張照片的網址。雖然如果你可以讓它們遵循某種模式,那很容易。 www.example.com/dir/photo1,www.example.com/dir/photo2。

您指向的外部服務器也必須允許遠程鏈接。

然後,它只是一個製作環節的事:

for ($i = 1; $i < NUMBER_OF_PHOTOS; ++$i) { 
    echo '<img src="http://www.example.com/dir/photo'.$i.'"/>'; 
} 
+0

是否意味着它不會加載外部圖像的圖像了,像上面的腳本? – jongmr

+0

是否意味着它不再加載外部文件夾中的圖像,就像上面的腳本一樣? – jongmr

相關問題