How do i store image and mp3 files to database. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do i store image and mp3 files to database.

13th Sep 2017, 7:28 PM
Ashish Kumar
9 Answers
+ 10
You could also use the common "BLOB" data type to store images, but MySQL is not the best option to do that... you would prefer alternatives like MongoDB or (even better, as stated by @Tashi) just store the absolute/relative path to the file. :)
13th Sep 2017, 8:17 PM
Maz
Maz - avatar
+ 9
Hmm. Usually you would store the path to your file in your database, not the files themselves.
13th Sep 2017, 7:34 PM
Tashi N
Tashi N - avatar
+ 7
The syntax of what? I don't even know which programming language and db we're talking about :)
13th Sep 2017, 9:23 PM
Tashi N
Tashi N - avatar
+ 2
I like to store files outside of my databases and store the path to the files in the database instead. If db storage space isn't a concern then I guess BLOB storage is acceptable, but if you want to make the most of your db storage (especially if building a website with a shared hosting plan with db size limits) then store your files outside of your database and save the path only.
14th Sep 2017, 2:22 AM
Mike
Mike - avatar
+ 2
oooooo advance Java. Surely if wielding such "advanced" technology you would know how to use it! Seriously though... all you're doing in this situation is storing a string (the path to your file) as a record in your db. Not the file itself. If you know how to connect to a database and insert a record, then you know how to save the path to your file. If you don't know how to connect to a database and insert a record, I'd start there first. There are thousands of examples online. Pick one and go.
14th Sep 2017, 2:57 PM
Mike
Mike - avatar
+ 1
Thanks.
14th Sep 2017, 3:23 PM
Ashish Kumar
0
Hmm. Usually you would store the path to your file in your database, not the files themselves. Could u send the syntax.
13th Sep 2017, 9:15 PM
Ashish Kumar
0
The syntax of what? I don't even know which programming language and db we're talking about :) I am using advance java with html and the db is oracle
14th Sep 2017, 2:45 PM
Ashish Kumar
0
I just have an another problem. How to use transitions in display attribute. Suppose i want to make a menu after clicking on it the content of menu will visible with transition.
14th Sep 2017, 3:28 PM
Ashish Kumar