Hello every
Am sudhakar learner of php. Am designing a website i want to insert some audio and image files in the database table. and also i want them to display from table. how can we insert such files and retrieve them please help me with the code.
Thank You.
send audio file to mysql database table
Moderator: General Moderators
-
sudhakar_ssr
- Forum Newbie
- Posts: 1
- Joined: Thu Aug 11, 2011 12:14 pm
-
ThatPerson
- Forum Commoner
- Posts: 50
- Joined: Wed Aug 03, 2011 1:57 am
Re: send audio file to mysql database table
I am not entirely sure what you mean, but I think to are wondering how you can display images from a MySQL database or insert them. If the images are local you could just have the path (../images/image.jpg) in the database and have:
To insert the image you could run this mysql
[text]insert into image database values("../images/image.jpg","Hi There");[/text]
Code: Select all
$img = mysql_fetch_object(mysql_query("select image from table where something = something else")) -> image;
echo "<div style="background:url($img)"></div>"; #I know, I use divs for images, it is a thing that I just constantly do[text]insert into image database values("../images/image.jpg","Hi There");[/text]
Re: send audio file to mysql database table
If I are referring to storing files in the database as "BLOB", then check out the link below for a code example on how to do it.
http://www.php-mysql-tutorial.com/wikis ... abase.aspx
http://www.php-mysql-tutorial.com/wikis ... abase.aspx
Re: send audio file to mysql database table
As indicated by the other 2 responses, this is quite possible, but it is the general opinion of many (if not most) web developers that it is better NOT to store binary data like audio and video and images in a database. As ThatPerson suggested, it is the customary method to store the path to the file in the database, then use that path to embed the href attribute in an appropriate HTML element, such as <img...> for images.