Reputation: 23
I want to display the image and the image url of a directory
I found this code, but there is a dot before the filename.
<?php
$files = glob("./images/*.*");
for ($i=0; $i<count($files); $i++) {
$image = $files[$i];
print "<textarea>";
print "http://" .$_SERVER['SERVER_NAME'].$image;
print "</textarea>"."<br />";
echo '<img src="'.$image .'" />'."<br /><br />";
}
?>
the result will be like this :
<textarea>http://domain.com./images/filename.png<textarea>
<img src="./images/filename.png" />
please help to fix this. thanks.
Upvotes: 0
Views: 3286
Reputation: 23
I solved the problem by using the following:
<?php
$files = glob("images/*.*");
for ($i=0; $i<count($files); $i++) {
$image = $files[$i];
echo '<img src="'.$image .'" />'."<br /><br />";
print "<textarea>";
print "http://" .$_SERVER['SERVER_NAME'].$image;
print "</textarea>"."<br /><br /><br />";
}
?>
Upvotes: 2