11-07-2008, 10:09 AM
|
#3 (permalink)
|
|
The Contributor
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
|
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( $file, 0, 1 ) != '.' )
{
// Put data in variables
$filename = $file;
$filesize = filesize( $directory_path . $file );
// Do your database magic here
}
}
?>
|
|
|