Page 1 of 1

Upload file, save to database, retrieve file.

Posted: Sat Feb 19, 2011 11:51 am
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?

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

Posted: Sat Feb 19, 2011 7:40 pm
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.