Jump to content

image script


maxbox

Recommended Posts

hello

 

i have this php code to show the last image upload in a folder and the result is this

 

http://theplattan.com/screenlive2/Screenshooter2.php

 

this code must be in the same image folder to work.

 

I need add a php code from my joomla website but i dont know where i can  change the  path image folder on this script.

 

i have tried by my self to change rad 33 $files = dirList('.');  to  $files = dirList('screenlive2');

 

but this show only the list and not the image, somebody have any idea?

 

 

1:
<html>
2:
<head>
3:
<style type="text/css">
4:
#files { float: left; font-size: small; }
5:
#image { float: right; }
6:
.links { float: right; left: -40px; position: relative; }
7:
.selected { font-weight: bold; }
8:
</style>
9:
</head>
10:
<body>
11:

12:
<?php
13:

14:
function dirList ($directory)
15:
{
16:
    $results = array();
17:
    $handler = opendir($directory);
18:
    while ($file = readdir($handler)) {
19:
       if ($file != '.' && $file != '..')
20:
         {
21:
            $suffix = "gif";
22:

23:
            if( substr($file, -3) == $suffix )
24:
            {
25:
            $results[] = $file;
26:
            }
27:
         }
28:
    }
29:
    closedir($handler);
30:
    return $results;
31:
}
32:

33:
$files = dirList('.');
34:

35:
arsort($files);
36:

37:
//$files = array_reverse( $files );
38:

39:
echo "<div id='files'><ul>";
40:

41:
$prev = "";
42:
$next = "";
43:
$last = "";
44:

45:
foreach( $files as $entry )
46:
{
47:
   if( isset($_GET['sel']) == false )
48:
   {
49:
      $_GET['sel'] = $entry;
50:
   }
51:

52:
   $style = "";
53:

54:
   if( $_GET['sel'] == $entry )
55:
   {
56:
      $style="selected";
57:
      $selected = $entry;
58:
      $prev = $last;
59:
   }
60:

61:
   echo "<li class='".$style."'><a href='i.php?sel=".$entry."'>";
62:
   print_r( $entry );
63:
   echo "</a></li>";
64:

65:
   if( ($last == $selected) && ($last != "") )
66:
   {
67:
      $next = $entry;
68:
   }
69:

70:
   $last = $entry;
71:
}
72:

73:
echo "</ul></div>";
74:

75:
echo "<div id='image'><img src='".$selected."' alt=''/></div>";
76:
   
77:
echo "<p class='links'>";
78:

79:
   if( $prev != "" ) echo "<a href='i.php?sel=".$prev."'>Up</a>";
80:
   echo "<br/>";
81:
   if( $next != "" ) echo "<a href='i.php?sel=".$next."'>Down</a>";
82:

83:
echo "</p>";
84:

85:
?>
86:

87:
</body>
88:
</html> 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.