Displaying images from URL

+2 Kaito Kaito · November 30, 2015
Hi everyone, I need your help.
I want to get all images from URL folder.
I will explain it more
I have two hosting servers : A & B
A = For running the website
B = For storing images

I want to display images that are stored in B in the server in my website A
for example: https://www.mydomain.com/folder1
folder1 has images
I want to display them using a loop in my website A

I hope you understood me

Post a Reply


Oldest  Newest  Rating
0 Kaito Kaito · December 7, 2015
I think you gays did not understand me.

"Is it possible for php to scan URL directory and pull the images to another website that is being hosted on another server?"
0 Ron Butcher · December 3, 2015
What Danny said.  You will need to have the fully qualified domain name for each image.  i.e.

<img src="http://www.mysite.com/imgFolder/imgName.png" alt="Something Cool" />

If you are looking to store a bunch of files in a folder and display them all, you will need a way of getting the names of the images.  Either from a hard coded array, a text file or from a database (preferred).

An array would look something like this:

//  The array with all of the image names
$imgArray = array ( "img1.png", "img2.png", "img3.png" );

//  Cycle through the array and print out the img tag for each pic
foreach($imgArray as $img)
    echo '<img src="http://mysite.com/imgFolder/'.$img.'" alt="Something Cool" />';
0 Kaito Kaito · December 2, 2015
Thank you Myron Ortiz for helping, but this is NOT what I'm looking for. This will work only in the same server. I want to get images from another server (From URL)
0 Myron Ortiz · December 1, 2015
Grabbed this from SO. This should work fine for you. 

$dirname = "media/images/iconized/";
$images = glob($dirname."*.png");
foreach($images as $image) {
echo '';

This one willwork as well

foreach(glob(IMAGEPATH.'*') as $filename){
   echo basename($filename) . "\n";
  • 1



Server-side, HTML embedded scripting language used to create dynamic Web pages.