Forum Moderators: coopster
I have a few questions though, for on i dont even know where to start. How to i associate a file in a directory with information on a database?
Second, i'll need to create thumbnails for index views. How do i do that?
I mean im a total n00b when it comes to using images with php. I tried to search for tutorials, but man there is some real crap out there that answer none of my questions.
If anyone can help me id really appreciate it. Ive been at this for hours and gotten nowhere.
1) The user submits a "New Image" form, where the only fields filled out are something like Image Title and Image Description.
2) Behind the scenes, a numerical ID is generated (can be autogenerated, or the user can assign a number via the form). From this ID (which is also the Primary Key), three new variables are created, each storing a file name: <?php $Photo1 = $ID."1.jpg";?>
3) This value is then inserted into the database along with the information the user has placed in the form.
4) Upon successful insertion, the user is brought to an upload form, where they choose which image to upload via radiobutton. The value of the radiobutton is pulled from the database using the ID as a filter. For instance, the first photo would be valued <?php echo $row_DataBase['Photo1']?> (Or whatever...I use Dreamweaver, so syntax isn't something I pay much attention to.)
5) This form then allows the user to upload these files however they wish, and uses GD to adjust the size of the images on the fly.
Play with it a bit. For my skill level, this was the easiest way to allow my client the ability to easily add photos to records. Instead of storing the photo...it stores the URL.
It's the simplest
The radio button gives the variable on how to name the uploaded file. This way the user doesn't have to worry about it. The database stores the name of the file, and the upload form renames, resizes and uploads it.
[edited by: coopster at 9:44 pm (utc) on Jan. 5, 2006]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]
Let's say your database row contains 4 fields:
1) ID <-primary key
2) Title <-Photo Title (ex. "Crazy Pic")
3) Desc <-Photo Description (ex. "Here I am, being Crazy!")
4) Photo1 <-Photo Filename (ex. "[IDnumberhere]1.jpg")
Fields 1, 2 and 3 would be submitted by the user via a form. Field 4 would be assigned in the next page. Since there's only one photo per entry, you don't need radio buttons, so ignore I said that. You'd just have a file upload script that will name the file to the value stored in Photo1 for that row.
Now, you can plug these values into your template.
I used something from hotscripts that did the trick with a little modification.
[picklegallery.sourceforge.net...]
Here is a demo:
[picklegallery.sourceforge.net...]
It indexes as much as you want, thumbs and if clicked gives full-size, categorizes and indexes everything, all you have to do is upload the files, literally. I think you need to tell it the directory on the server where the images are located, everything else is automatic.
I have more than a few thousand images indexed thusly, over 200 categories, it even creates subs for you. If you want it to look fancy, get a nice background and configure the header file.
Now if you want your site's VISITORS to be able to play with the file-system, that's another story.