Jump to content


Photo

Storing jpgs or gifs directly in a DB.


  • Please log in to reply
2 replies to this topic

#1 dbrimlow

dbrimlow
  • Members
  • PipPipPip
  • Advanced Member
  • 712 posts

Posted 19 December 2005 - 09:28 PM

I am creating a form that among various and typical fields, there is a photo upload.

My user is a specialized real estate agent, so I need to attempt using as few steps as possible for them to enter the listing data.

Usually, I edit, name and upload photos to a folder and have a link in the db (the photo naming conventions I use are the listing ID# (234567a, 234567b, etc.).

But in this case, I simply want to automate the process as much as possible. This bozo is not going to rename the photos, so creating two forms will not help the photo associate with the listing ID.

I was thinking of simply uploading the photo and inserting it into the DB along with the other fields.

Can, and if so, how, would one upload binary media like photos, mp3s, etc.?

I tried making the field, blog-binary, and it did upload, but I haven't tried to display it, yet. Of course, doing a query in phpmyadmin just shows the actual binary code.
Dave

I am always amazed by no matter how much I know, I know I don't know as much as I thought I knew.  - D. Brimlow.

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 23 December 2005 - 10:21 PM

First, even with a standard upload form, you should be able to automatically change the name of the uploaded file to whatever you want -- including the listing ID -- so I don't understand why this is a problem.

Second, storing binary data in BLOBs is OK, as long as a) you store the BLOBs in their own table with a foreign key referencing the listings and b) you don't store the entire binary data object in a single BLOB field.

Take a look at [a href=\"http://php.dreamwerx.net/forums/viewtopic.php?t=6\" target=\"_blank\"]this excellent tutorial[/a] -- it covers all of the scripting, and addresses my two caveats above as well.

Hope that helps.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 dbrimlow

dbrimlow
  • Members
  • PipPipPip
  • Advanced Member
  • 712 posts

Posted 23 December 2005 - 10:39 PM

[!--quoteo(post=330058:date=Dec 23 2005, 05:21 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Dec 23 2005, 05:21 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
First, even with a standard upload form, you should be able to automatically change the name of the uploaded file to whatever you want -- including the listing ID -- so I don't understand why this is a problem.

Second, storing binary data in BLOBs is OK, as long as a) you store the BLOBs in their own table with a foreign key referencing the listings and b) you don't store the entire binary data object in a single BLOB field.

Take a look at [a href=\"http://php.dreamwerx.net/forums/viewtopic.php?t=6\" target=\"_blank\"]this excellent tutorial[/a] -- it covers all of the scripting, and addresses my two caveats above as well.

Hope that helps.
[/quote]

Thanks. I decided to do the smart thing and simply have the photo upload as a pop-up ( after the form submit is clicked) that loads them to a folder, renames them (12345a, b, c, d, etc) which auto associates them with the listing ID. I'll have the form include a hidden link to the photos file using the listing ID (12345a,b, c, d) pointing to the folder where photos are stored.

I appreciate the reply.

Dave

Dave

I am always amazed by no matter how much I know, I know I don't know as much as I thought I knew.  - D. Brimlow.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users