For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > November 2005 > Retrieving images dynamically from folders









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Retrieving images dynamically from folders
FayeC

2005-11-17, 6:56 pm

I have created a site in Joomla with a login (no self registration,
users are provided with username and password by the admin).
The users are supposed to login to a specific page where they can see
4 images.
I have the following code:
<?php
// define directory path
$dir = "images/user1/";

// iterate through files
// look for JPEGs
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (preg_match("/.jpg/", $file)) {
// read EXIF headers
$exif = exif_read_data($file, 0, true);
echo "<tr>";
// get thumbnail
// link to full image
echo "<td valign=top><a
href=$dir/$file><imgsrc=thumbnail.php?file=$file></a><td>";
echo "<td valign=top><font size=-1>";
// get file name
echo "File: <b>" . $exif['FILE']['FileName'] .
"</b><br/>";
// get timestamp
echo "Timestamp: " . $exif['IFD0']['DateTime'] .
"<br/>";
// get image dimensions
echo "Dimensions: " . $exif['COMPUTED']['Height'] . "
x " . $exif['COMPUTED']['Height'] . " <br/>";
// get camera make and model
echo "Camera: " . $exif['IFD0']['Model'];
echo "</font></td>";
echo "</tr>";
}
}
closedir($dh);
}
}
?>

The question now is how to change the code to dimamically replace the
folder name by the login username used.
For example....if user2 logs in the images loaded will be only those
in the folder images/user2, if user3 logs in it will be from the
folder images/user3, etc...
I am a little as to how to implement that in Joomla but as
long as I have the code right I thinkI can just insert the code into
the appropriate page using a mambot.
If anybody here has any tips on how to accomplish that it would be
extremely appreciated.
Thank you in advance,


FayeC
Connector5

2005-11-18, 3:55 am


$dir = "images/" . $username;

???


"FayeC" <fayec_web@hotmail.com> wrote in message
news:o5mpn11hmur13elq609cijb1k24kj38c4k@
4ax.com...
> I have created a site in Joomla with a login (no self registration,
> users are provided with username and password by the admin).
> The users are supposed to login to a specific page where they can see
> 4 images.
> I have the following code:
> <?php
> // define directory path
> $dir = "images/user1/";
>
> // iterate through files
> // look for JPEGs
> if (is_dir($dir)) {
> if ($dh = opendir($dir)) {
> while (($file = readdir($dh)) !== false) {
> if (preg_match("/.jpg/", $file)) {
> // read EXIF headers
> $exif = exif_read_data($file, 0, true);
> echo "<tr>";
> // get thumbnail
> // link to full image
> echo "<td valign=top><a
> href=$dir/$file><imgsrc=thumbnail.php?file=$file></a><td>";
> echo "<td valign=top><font size=-1>";
> // get file name
> echo "File: <b>" . $exif['FILE']['FileName'] .
> "</b><br/>";
> // get timestamp
> echo "Timestamp: " . $exif['IFD0']['DateTime'] .
> "<br/>";
> // get image dimensions
> echo "Dimensions: " . $exif['COMPUTED']['Height'] . "
> x " . $exif['COMPUTED']['Height'] . " <br/>";
> // get camera make and model
> echo "Camera: " . $exif['IFD0']['Model'];
> echo "</font></td>";
> echo "</tr>";
> }
> }
> closedir($dh);
> }
> }
> ?>
>
> The question now is how to change the code to dimamically replace the
> folder name by the login username used.
> For example....if user2 logs in the images loaded will be only those
> in the folder images/user2, if user3 logs in it will be from the
> folder images/user3, etc...
> I am a little as to how to implement that in Joomla but as
> long as I have the code right I thinkI can just insert the code into
> the appropriate page using a mambot.
> If anybody here has any tips on how to accomplish that it would be
> extremely appreciated.
> Thank you in advance,
>
>
> FayeC



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com