Jump to content

Archived

This topic is now archived and is closed to further replies.

dbrimlow

Storing jpgs or gifs directly in a DB.

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

[!--quoteo(post=330058:date=Dec 23 2005, 05:21 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Dec 23 2005, 05:21 PM) 330058[/snapback][/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.

 

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

 

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.