Upload file, save to database, retrieve file.

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
cupaball
Forum Commoner
Posts: 85
Joined: Sun Feb 12, 2006 1:46 pm

Upload file, save to database, retrieve file.

Post by cupaball »

Here is what I am trying to accomplish. I want to create a backend for my client to use that will allow the following:

1. Allow them upload a max of 5 photos
2. The first photo will resize as a thumbnail, medium size and large size files into different folders
3. The other photos will save as medium and large size files in their respective folders
4. The names of each photo will save into a database (I will need to only call the medium photo sometimes)

So far I can do the multiple file upload, resize, and save into their respective folders using arrays and the foreach loop.

The challenge I am running into is that I can't figure out how to save the file/location to a separate column in a database (ie. thumbnail, medium, large).

Any suggestions?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Upload file, save to database, retrieve file.

Post by s.dot »

I would name the images appropriately, md_imagename.jpg and lg_imagename.jpg and th_imagename.jpg, and store "imagename.jpg" in the database column. Where you need the medium image, call 'md_' . $imageNameFromDb and when you need the large image, do 'lg_' . $imageNameFromDb and where you need the thumbnail, do 'th_' . $imageNameFromDb.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply