View Single Post
Old 11-07-2008, 10:09 AM   #3 (permalink)
Runar
The Contributor
 
Runar's Avatar
 
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
Runar is on a distinguished road
Default

I made a simple example. It will return all visible files (hides files starting with .), including folders. If you want to confirm that the file in fact is an image before doing anything with the result, then you will have to modify it yourself, or let me know.

PHP Code:
<?php

// Turn on error reporting
ini_set'display_errors''yes' );

// Set path to our directory (for easier use)
// Remember the last slash (/)!
$directory_path 'your/image/folder/';

// Open the directory
$directory opendir$directory_path );

// Read the directory content
while( ( $file readdir$directory ) ) !== false )
{
    
// Drop hidden files and files which names begins with a dot
    
if( substr$file0) != '.' )
    {
        
// Put data in variables
        
$filename $file;
        
$filesize filesize$directory_path $file );
        
        
// Do your database magic here
    
}
}
    
?>
Send a message via MSN to Runar
Runar is offline  
Reply With Quote