11-07-2008, 10:55 AM
|
#6 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by Runar
Like this? The code below is tested with positive result.
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/';
// Return .png files found in the directory
foreach( glob( $directory_path . '*.png' ) as $file )
{
// Put data in variables
$filename = basename( $file );
$filesize = filesize( $file );
// Do your database magic here
}
?>
|
Correct!
Thought, he could also use it like this:
php Code:
glob($directory_path . '{*.png,*.jpg,*.gif}', GLOB_BRACE )
to support other than just .png that you had.
Read here: Traverse Directories the Easy Way with Glob() !
A great tutorial by Wildhoney.
__________________
|
|
|
|