I'm trying to:
1. upload (say, 100 images) to a folder.
2. Create a database of that 100 images. (which contains something like name, artist, etc.)
Could anyone please give me a guidance on how to do this with PHP please? (only for step 2. I can just use ftp for step 1)
Thank you in advance.
How to create a database of "files in the folder"?
Moderator: General Moderators
- novice4eva
- Forum Contributor
- Posts: 327
- Joined: Thu Mar 29, 2007 3:48 am
- Location: Nepal
Re: How to create a database of "files in the folder"?
lets say your pictures are in directory pics/ then:
Code: Select all
$dir = 'pics/';
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if(!(strcmp($file,'.')==0 || strcmp($file,'..')==0))
{
$content = file_get_contents($dir.$file);/*YOUR PICTURE IS HELD IN THIS VARIABLE, BUILD SQL TO INSERT THIS INTO THE TABLE*/
}
}
closedir($dh);
}
}