Reputation: 2346
I am new to PHP, I have repository on my linux server, where web is hosted.
I have images folder Like /myfolder/image1-user etc. I want to display that on my web portal album. How can i do this?
EDIT I have iterated the directory where pictures are stored. Now i have array list of path to the images, i used IMG SRC tag to show, but nothing is being shown, also i want URL of the each file in the repository that contains photos, i have link to image like this /myrepo/photos/photos-1/1.jpg and so on
Upvotes: 0
Views: 612
Reputation: 965
symlink!
Say you want to display from your web root, e.g. /imgs/photos and your document root is the default '/var/www'
Then symlink that to the real folder below the webroot, for example:
ln -s /real/path/to/my/photos /var/www/imgs/photos
(on command line)
Then, when in your html you use src="/imgs/photos/great-photo.jpg" it will display "/real/path/to/my/photos/great-photo.jpg"
This may not work if you're on a shared hosting virtual server environment with all kinds of restrictions (such as open basedir etc.)
Upvotes: 0
Reputation: 1634
You have to iterate over the folder where your images are stored.
<?php
if ($handle = opendir('/path/to/files')) {
echo "Directory handle: $handle\n";
echo "Entries:\n";
/* This is the correct way to loop over the directory. */
while (false !== ($entry = readdir($handle))) {
echo "$entry<br/>";
}
closedir($handle);
}
?>
Upvotes: 1