This code lets you display the images in a directory; limiting size - with option to display filesize - and filename.
It also lets you selective ignore files by name.
(may be a little sloppy, but its all mine)
By : Kender
<?
/* ************************************
** James Wheeler
** Kender Internet Kompany
** http://kender.org
**
** Name as index.php
** - Display all images in a directory
** - Able to skip files at will
** - remove <img src= and use for
** all files in directory
** (skipping desired files)
**
** Code free to use, please give credit
** where credit is due!
************************************ */
echo '<center>
Click on a thumbnail to view image<br />
<table>
<tr>
';
$main = ".";
$dir = opendir($main); // unbutton it
$i = 1; // for column count
while($filename = readdir($dir))
{
{
if (filetype($filename) == "file" && $filename != "index.php")
// dont show index.php (this file) - skip any file you dont want viewed
// format as ( && $filename != "filename.ext" ) inside the () behind "index.php"
{
if ($i <= '5') // column count (designed for 5 columns wide - change the 5 for however many wanted)
{
$i = $i + '1';
echo ' <td align="left" width="115" height="100">
<a href="'.$filename.'"><img src="'.$filename.'" height="60" border="0" /></a><br />
<font size="1" face="tahoma">'.$filename.'<br />'.filesize($filename).' bytes.</font>
</td>
'; // display it
} else {
$i = '1'; // reset column count and change rows
echo ' </tr>
<tr>
';
$i = $i + '1'; // add 1 to counter to get to next row
echo ' <td align="left" width="115" height="100">
<a href="'.$filename.'"><img src="'.$filename.'" height="60" border="0" /></a><br />
<font size="1" face="tahoma">'.$filename.'<br />'.filesize($filename).' bytes.</font>
</td>
'; // display it
}
}
}
}
closedir($dir); // button it up
echo '
</tr>
</table>
</center>
';
exit;
?>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More File Manipulation Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies. FREE! Go There Now!
|
|
|
|
Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services. FREE! Go There Now!
|
|
|
|
This paper is about the critical role that a discipline called integrated requirements management can play in helping to ensure that your business goals and IT investments are continuously aligned—whether you are sourcing, integrating, building or maintaining software. It also looks at ways that automated IBM Rational® products can work together to help you use requirements in the very best way. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference on November 29 at 1:00 pm ET to participate in an interactive discusssion with Grady Booch around architecture and reuse. Get your questions answered! FREE! Go There Now!
|
|
|
|
Join us for this on demand webcast to learn about developing complex systems more quickly and efficiently. We'll cover market drivers for developing, governing and reusing systems software assets and how you can develop system software assets with Rational Asset Manager. FREE! Go There Now!
|
|
|
|
This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product. FREE! Go There Now!
|
|
|
|
Get a free trial download of IBM Lotus Forms V3.0 (formerly Workplace Forms), which provides a zero-footprint eForms solution to help you automate and move forms-based business processes off the desktop and onto the Web. With Lotus Forms, you can extend applications beyond the firewall by creating a single electronic form document ready for use in both thick and Web 2.0 thin client format. FREE! Go There Now!
|
|
|
|
As organizations integrate software into every aspect of business, they are constantly pressured to deliver faster, better, and cheaper results. Unfortunately, a “dis-integrated” software delivery approach reduces returns while increasing costs. This IBM Rational White Paper shows how Integrated Requirements Management aligns organizations around maximizing value and keeping pace with change. FREE! Go There Now!
|
|
|
|
As businesses grow increasingly dependent upon Web applications, these complex entities grow more difficult to secure. Most companies equip their Web sites with firewalls, Secure Sockets Layer (SSL), and network and host security, but the majority of attacks are on applications themselves – and these technologies cannot prevent them. This paper explains what you can do to help protect your organization, and it discusses an approach for improving your organization’s Web application security. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial version of WebSphere Extended Deployment Compute Grid, which lets you schedule, execute, and monitor batch jobs. Because online transaction processing and batch jobs execute simultaneously on the same server resources, you can avoid costly duplication of resources. Compute Grid supports job types of Java transactional batch, compute-intensive and a new type called "native execution", which enables non-Java workloads to run on distributed end points. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |