How do you link images from a domain to a subdomain in PHP?
I have a slider on my main site. I want to use the same images on my mobile site which is subdomained at m.mysite.com
I have tried to following code(which I use for my current slider):
<?php
$files = glob('images/gallery/*.{jpg,png,gif}', GLOB_BRACE);
foreach($files as $file) {
echo "<div class='slide'><a href=''><img src='" . $file . "' alt='description'></a></div>";
}
?>
Nothing happens. So I modify my code to this:
<?php
$files = glob('../images/gallery/*.{jpg,png,gif}', GLOB_BRACE);
foreach($files as $file) {
echo "<div class='slide'><a href=''><img src='" . $file . "' alt='description'></a></div>";
}
?>
This time it kinda works. It outputs this:
<div class='slide'><a href=''><img src='../images/gallery/1012081_1501438913448804_6782879489506876198_n.jpg' alt='description'></a></div>
<div class='slide'><a href=''><img src='../images/gallery/10177464_1495074060751956_373648277891171115_n.jpg' alt='description'></a></div>
All of the images are "broken".
When I click the img src in the source code I get this: http://m.example.com/images/gallery/1012081_1501438913448804_6782879489506876198_n.jpg
It seems as though the code is looking in the right directory, makes a div for each image, but then adds the m. to the beginning.
How can I fix this to where it does not look in the mobile directory for these images?
To make it simple the image link should be http://example.com/images/gallery/1012081_1501438913448804_6782879489506876198_n.jpg
Thanks guys.