WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : PHP Image Gallery -> Read through a folder of images and distribute them to the gallery folders
Categories : PHP, Filesystem, Graphics Click here to Update Your Picture
Christian Haensel
Date : Jun 14th 2007
Grade : 3 of 5 (graded 4 times)
Viewed : 4630
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Christian Haensel
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

This script is taking a directory of images with the filename structure "galleryname_1.jpg",
"gallery_2.jpg" ... and creates subdirectories based on the first part of the image filename.
So an image file with the name "bulldozer_1.jpg" would cause the script to check for the
directory "albums/bulldozer/". If it doesn't exist, it'll create it. If it exists, it will
check whether the file exists already in the directory. If it doesn't, it'll copy it to the
"bulldozer" directory.

This way you can upload your image files in one directory after having them renamed with your
windows OS or whatever and distribute them into single albums.


<?
/*
This script has been programmed by Christian Haensel, chris@chftp.com. LINK1http://www.chftp.comLINK1
Please do not remove this information.
If you like this script, please let me know and/or link to my website from your website.
*/

// Name of the directory where the source images reside that you wanna put in place.

$tmpdir        =    "imgtmp";

// Create folders if not existant
function createdir($checknr) {
   
mkdir("albums/".$checknr, 0777);
   
chmod ("albums/".$checknr, 0777);
    echo
"<p>DIR <b>".$checknr."</b> created<br>";
}


// Check if the image already exists. Otherwise copy it into the directory
function check_image($checknr, $filename) {
    if(
file_exists("albums/".$checknr."/".$filename)) {
        echo
" File ".$filename." exists";
    } else {
       
copy('imgtmp/'.$filename, "albums/".$checknr."/".$filename);
        echo
" File ".$filename." copied";
    }
}

// Check if the image folder exists
function checkfolder($check, $movefile) {
    if(!
is_dir("albums/".$check)) {
       
createdir($check);
       
check_image($check, $movefile);
    } else {
       
check_image($check, $movefile);
    }
}

// Run through the source folder
$folder        =    opendir($tmpdir);
while(
$file    =    readdir($folder)) {
    if(!
is_dir($file)) {
       
$checkfile    =    explode("_", $file);
       
$checknr    =    $checkfile[0];
       
checkfolder($checknr, $file);
        echo
"<br>";
    }
}
?>



This is a simple photo gallery that reads the image files from multiple directories, and generates a web page styled with CSS1. It opens single auto window to view and print a given image.
Categories : Graphics, Filesystem, PHP, Complete Programs
Random Image Display
Categories : PHP, Filesystem, Graphics, HTML and PHP
Easy slideshow with php. Just place this one file into a subdirectory where jpg files reside. An instant slideshow is yours. MS explorer only.
Categories : PHP, Filesystem, Graphics
This program implements hot link prevention in php. It is useful for webmasters who do not have access to the server at a level where they can control hot linking can still supply some type of hot link prevention for thier site by using php.
Categories : PHP, Filesystem, Graphics, Content Management
This script will read all images from a folder and read the files into an array. It uses rand() to get a random number. It will display a random image from the image folder given.
Categories : PHP, Arrays, Graphics, Filesystem
Simple image counter
Categories : PHP, Graphics, Filesystem, Beginner Guides
Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs
PHP4 DirectoryIterator Class
Categories : PHP, PHP Classes, Filesystem, Directories
Keep() - maintenance function for backup folders
Categories : PHP, Filesystem, Maintenance
Shows the current time as a PNG-image. This script does not use the GD library. You can use it as a benchmark (because it's slow), or as a quick reference for implementing a simple PNG-file generator.
Categories : Graphics, Zlib, Calendar, PHP, Date Time
Contents Page - a script to build contents pages.
Categories : Complete Programs, PHP, Utilities, Filesystem
Display list of files within current and subdirectories (recursively) showing each file as an anchored link and each directory as a category header.
Categories : Filesystem, Directories, Arrays, PHP
How to create an empty file? (touch)
Categories : Filesystem, PHP
A couple of functions that convert an IP address into its color code and not-color-code. Useful when viewing an apache log with a mysql result grouped by IP
Categories : PHP, Graphics, Databases
Simple way of scaling any image to fit either given width or height.
Categories : PHP, Graphics, Arrays