0

Possible Duplicate:
Where to store uploaded files (sound, pictures and video)

I am making a website where the user registers and signs in and then they can upload their own music files. Should I store the music files that they upload as a blob in a MySQL DB table? or how else could I possibly store the files so they can be played through an HTML 5 media player? I have tried researching this online and all I can find is that it wouldn't be good to store the files in a MySQL table.

Community
  • 1
  • 1
Worm
  • 141
  • 6
  • 18

2 Answers2

1

Yous should upload them into a directory on your server. You associate a file name and or id with the song and user to retrieve them from the database when needed.

Paul Dessert
  • 6,363
  • 8
  • 47
  • 74
  • what if I only want the user that uploaded the songs to be able to listen to them? like I want them to be completely private to everyone but whoever uploaded them, sorry I forgot to add that part – Worm Nov 15 '12 at 23:42
  • @worm use the DB to track what songs/IDs someone has access to – ernie Nov 15 '12 at 23:43
  • Same concept. You have to write the logic that associates the user to the song. – Paul Dessert Nov 15 '12 at 23:43
  • store them outside the web root and server them via a script –  Nov 15 '12 at 23:43
  • private to somebody is not related to how to store your music. usually we store music into files in the server to maintain them more easily – user1283182 Nov 15 '12 at 23:46
  • @ernie are you saying to give each song an id and then store in the user DB what id's a certain user can access? – Worm Nov 15 '12 at 23:46
  • 1
    @worm exactly; the ID would be tied to a location on disk, and each user in your DB would have a list of IDs they could access. – ernie Nov 15 '12 at 23:47
1

In regards to storing the media file, best to store them on the server somewhere, or even better store them on a CDN.

In regards to storing the details of the music, create a table in your mysql, call it something like music_meta and then save details about the files location, name, size etc.

Kyle Hudson
  • 898
  • 1
  • 14
  • 26