0

I am programming a website where I need to store mp3 files in a database. I am using phpMyAdmin and mySQL for my database and am programming the website using html/php/css/javascript.

After doing some research, I have found that a good method for doing this is to not to store the actual mp3 file in the database, but to store the path to the file and to store the mp3 file on the "filesystem".

I am new to web development, so what do people mean by "filesystem" and how would I save/retrieve an mp3 file to the "filesystem"?

  • 1
    You just put it in filesystem, like how you do in your computer. If you want users to upload mp3 files, you will need an html form and upload script. After file is moved to it's folder, get the path and save it to DB – Оzgur Apr 16 '17 at 22:04

2 Answers2

1

Say your users upload files to your server (like you do when you add an image to Facebook, or any other site). In your case, mp3-files. These files are stored on your server - either in one general folder, or in subfolders belonging to each user (the latter might be better to avoid people uploading files with the same name, overwriting other files, etc.) - your upload script needs to put these files where you want them AND store this path with the file-name in the database. Technically, if you know the file-path beforehand (which you should do), all you need to store in the database is the fileNAME.

That being said - you might not need to store files or filenames in the database at all. You can just read the folders (would need a folder per user, probably) and parse the files found in the folders, and show those.

Your level of knowledge seems maybe a little less than what I would recommend for something like this (there are a lot of pitfalls allowing people to upload files to your server, if that's what you're planning on doing), and you might wanna train a bit, learn a bit more, before doing something like this.

At least I would recommend perhaps using a ready-made upload script to help you with the logistics.

junkfoodjunkie
  • 3,168
  • 1
  • 19
  • 33
1

Very similar to: Stackoverflow -> Filesystems

I personally save files to a directory within my websites directory, though you can also save them outside the directory. A database entry can be used to hold the file path for retrieval. This is far less foot print on your server. You can also choose to save an XML file over a DB entry if you wish as well, there are many options, but I think as you look around you will find the option to save on a directory and use DB for the file path to be the standard.

Check out the basics as W3: File upload using file path

Community
  • 1
  • 1
dale landry
  • 7,831
  • 2
  • 16
  • 28