Connecting Tech Pros Worldwide Help | Site Map

Audio File uploads to database tables - what "type" do I define it as?

Newbie
 
Join Date: Jun 2007
Posts: 2
#1: Jun 1 '07
Hey there. I will not pretend to know more than I do...I'm just getting my feet wet with Dreamweaver and MySql databases. What I'm trying to do is create a form that will allow members to submit an audio file (mp3 or .wav) from a website. The form will insert the record into the database IF I can get it configured correctly. Here's the problem- I don't know what type to list the field as in order to get it to accept a file upload. Is this even possible?

I have the tables set up in the database and I have the insert record form page written in php (thanks to Dreamweaver). Can anyone offer any advice on how I can allow submission of audio files?

If I'm not being specific enough, please let me know and I'll try to better explain.

Thanks!
Cowgurl Art
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Jun 3 '07

re: Audio File uploads to database tables - what "type" do I define it as?


Heya, cowgurl art. Welcome to TSDN!

You have two options:
  • You can create a BLOB ('Binary Large OBject') field and store the files directly in the database (use file_get_contents to output the data as a string), or...
  • Your script can copy the uploaded file to a directory on your server (using move_uploaded_file) and then store the path to the file in the database instead.
Newbie
 
Join Date: Jun 2007
Posts: 2
#3: Jun 4 '07

re: Audio File uploads to database tables - what "type" do I define it as?


Quote:

Originally Posted by pbmods

Heya, cowgurl art. Welcome to TSDN!

You have two options:

  • You can create a BLOB ('Binary Large OBject') field and store the files directly in the database (use file_get_contents to output the data as a string), or...
  • Your script can copy the uploaded file to a directory on your server (using move_uploaded_file) and then store the path to the file in the database instead.

Thank you for this reply. I did give up and decided to upload the file via ftp to the server and just input the url to the file in the insert record form on the website. So, I took the easy way out.

I thought it should be a BLOB but I didn't know how to make the "insert record form" accept the blob. I'll think on this now that you've given me some help and maybe I can work it out. Thanks!
Newbie
 
Join Date: Jun 2007
Posts: 1
#4: Jun 15 '07

re: Audio File uploads to database tables - what "type" do I define it as?


I'm doing a similar project myself.

Between the two (upload or store in a DB), why would I want to choose one over the other?
e.g. Does one take up more physical space? Does one have less overhead?
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,745
#5: Jun 15 '07

re: Audio File uploads to database tables - what "type" do I define it as?


Quote:

Originally Posted by cat1205123

I'm doing a similar project myself.

Between the two (upload or store in a DB), why would I want to choose one over the other?
e.g. Does one take up more physical space? Does one have less overhead?

It would depend on what you want to do with your files.

It is probbly simpler to save files onto the file system. That way also makes retreiving them much simpler.
On the other hand, if your files contain sensetive data, they would be much more secure inside the DB, and you would have much more control over how they are handled.

You will have to jump through some hoops to insert and retreive them from the database, which many people will say can cause some extra overhead, but I think that's more of a myth than a fact. Most extra overhead is caused by poorly designed code.

Anyways, If you want people to have easy access to the files, I would upload them the old fashion way. If you want them keep them away from people, I would put them on the Database.

But thats just me.
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#6: Jun 15 '07

re: Audio File uploads to database tables - what "type" do I define it as?


Quote:

Originally Posted by Atli

Anyways, If you want people to have easy access to the files, I would upload them the old fashion way. If you want them keep them away from people, I would put them on the Database.

Even then, all you'd have to do is store the files outside your webserver's document root and use include or fread to access them.

The major difference in my opinion is that a CMS that stores files in the database is a pain in the butt to maintain, especially when somebody else wrote it (can you tell what I'm working on right now? :P).
Reply