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! |
Effective governance for lean development isn’t about command and control. Instead, the focus is on enabling the right behaviors and practices through collaborative and supportive techniques. Hear from Scott Ambler on how it is far more effective to motivate people to do the right thing than it is to force them to do so. Learn how to form a lightweight, collaboration-based framework that reflects the realities of modern IT organizations. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM Rational Software Analyzer Developer Edition V7.0 to identify bug defects earlier in the software development cycle. Rational Software Analyzer is an extensible software development solution that reduces the expense of bug-fixes by enabling static analysis code reviews and bug identification very early in the development cycle. FREE! Go There Now!
|
|
|
|
Join us for this web seminar to learn how you can defend your web applications from attack. Learn about the 3 most common web application attacks, including how they occur and what can be done to prevent them. We’ll also discuss manual versus automated approaches for scanning and identifying web application vulnerabilities and how IBM Rational AppScan, an automated vulnerability scanner, can help you automate more of what you are doing manually today. FREE! Go There Now!
|
|
|
|
Learn how Rational Build Forge can extend a simple compile and package build process by adding customization and deployment capability. Go from a manual method to automating: checking for code changes; getting the latest source; compiling and packaging; customizing; copying to and restarting a deployment server; and sending e-mail notification that a new version is available. FREE! Go There Now!
|
|
|
|
Asset Reuse is a key strategy for companies looking to create innovative solutions to solve complex software development problems. Searching for, identifying, updating, using and deploying software assets can be a difficult challenge. Listen to this webcast, to learn about strategies and tools that you can leverage for a successful project, including Rational Asset Manager, Rational Software Architect and WebSphere Service Registry and Repository. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference on December 4 at 1:00 pm ET to discuss how Rational Method Composer can help meet your compliance objectives. Get your questions answered! FREE! Go There Now!
|
|
|
|
Discover how Rational tools and best practices for testing can make your job easier. The new Rational Testing eKits provide you with valuable resources – including demos, webcasts, tutorials, and articles – that help you address your specific testing needs across the software lifecycle. Five new eKits are available covering the topics of Requirements and Test Management, Functional Testing, Performance Testing, Code Quality and Embedded Systems, and SOA and Web Services Testing. FREE! Go There Now!
|
|
|
|
Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1. 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!
|
|
|
|
Try the latest version of IBM Rational Manual Tester V7.0.1 by downloading a free trial from IBM developerWorks. This manual test authoring and execution tool promotes test step reuse to reduce the impact of software change on testers and business analysts and addresses the needs of teams performing at least a portion of their testing manually. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |