![]() |
Adding Images to a database from a folder
Hey all
I am currently working on a new gallery script and i thought i would show my script on adding images to a database that are in a folder. This can be very helpful if you don't want to add them all one at a time. First things first need to connect to the database. You can do this in your own way. PHP Code:
PHP Code:
first we want to stop other files from being added including the "." & ".." folders plus any files like index or something. PHP Code:
Title - Title of the image Date - Date is was submitted About - Information about the image Views - Number of views Filename - The file name of the image "image.jpg" Now because we are adding images via a folder we dont know anything about the image as in a description or even the actual title of the image the user wants, but this system allows for easy adding of images in a short time. So we can actually add some basic information for each image that the user can then change later. PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
|
Glob would look much neater than readdir :-( ! I personally think they should remove all the others and leave us with glob. |
Thank you Wild I shall take that into account :-D i agree with you.
|
Quote:
glob(), it's much easier to design with readdir() and scandir() than glob. You're making it out to be annoying, when it really isn't. Just don't use it if you hate it.I wrote a tutorial seven months ago that you probably read, if you visit Pixel2Life and read tutorials there, about implementing recursive searches--and helped someone extend it to include keyword searching as well. It wouldn't be hard, at all, to check for an extension on the end of that. For one directory, sure glob is nice, otherwise forget it. I used scandir to get all elements within the directory, and then discern what I wanted to do with them from there. |
| All times are GMT. The time now is 07:43 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0