Page 1 of 1
send audio file to mysql database table
Posted: Thu Aug 11, 2011 12:16 pm
by sudhakar_ssr
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.
Re: send audio file to mysql database table
Posted: Thu Aug 11, 2011 1:02 pm
by ThatPerson
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:
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
To insert the image you could run this mysql
[text]insert into image database values("../images/image.jpg","Hi There");[/text]
Re: send audio file to mysql database table
Posted: Thu Aug 11, 2011 8:55 pm
by xtiano77
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
Re: send audio file to mysql database table
Posted: Thu Aug 11, 2011 9:18 pm
by califdon
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.