script to insert all files from directory into db

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpuppy
Forum Newbie
Posts: 2
Joined: Tue Jul 08, 2008 10:53 pm

script to insert all files from directory into db

Post by phpuppy »

Hello all,

I've been looking around for a while at scandir and other php functions for a way to insert all files in a given directory into a table and can't seem to get it. The files would have a sequential order like 1.jpg, 2.jpg, 3.jpg, etc.

Can someone give a link on a tutorial or, better yet, the script on how to do it?

Thanks!
phpuppy

PHP 5.2.5 - MySQL 5.0.45
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: script to insert all files from directory into db

Post by jayshields »

If you read the example on http://uk3.php.net/opendir it will give you a starting point for iterating over a directory of files.

Also the examples on http://uk2.php.net/mysql_query will probably help.
phpuppy
Forum Newbie
Posts: 2
Joined: Tue Jul 08, 2008 10:53 pm

Re: script to insert all files from directory into db

Post by phpuppy »

Gee, thanks, a link back to the manual... how helpful.
Post Reply