spires Posted July 17, 2006 Share Posted July 17, 2006 Hi, Can any one tell me if its posiable to Upload mp3s to your database or server?I've been looking on php.net but cant find anything on this. I now know hoe to upload images to the server, is it done in the same way?I'm try to build a shopping cart from a musician, and have the cart play a sample of the mp3,so customers can hear the track before they buy.Thanks Quote Link to comment https://forums.phpfreaks.com/topic/14880-uploading-mp3s-to-database-or-server/ Share on other sites More sharing options...
effigy Posted July 17, 2006 Share Posted July 17, 2006 Yes. Anything can be uploaded. I prefer to store the files in the OS, and the paths in the database. Quote Link to comment https://forums.phpfreaks.com/topic/14880-uploading-mp3s-to-database-or-server/#findComment-59597 Share on other sites More sharing options...
spires Posted July 17, 2006 Author Share Posted July 17, 2006 do you know of any good articles on this?as every time i type anything to do with mp3s in to google, it comes back with torrent sites. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/14880-uploading-mp3s-to-database-or-server/#findComment-59598 Share on other sites More sharing options...
effigy Posted July 17, 2006 Share Posted July 17, 2006 A typical upload tutorial should suit your needs. The customizations are that you're looking for different extensions (.mp3) and different file types (audio/mp3). Quote Link to comment https://forums.phpfreaks.com/topic/14880-uploading-mp3s-to-database-or-server/#findComment-59600 Share on other sites More sharing options...
redarrow Posted July 17, 2006 Share Posted July 17, 2006 example ok[code]---------form-----------------------------------------------------------<html><head><body><h1>please upload music!</h1><br><form enctype="multipart/form-data" action="members_upload_music_result.php" method="post"><input type="hidden" name="MAX_FILE_SIZE" value="320834100"><br>please choose a music file<br><input type="file" name="userfile"><br><input type="submit" value="send"><br></form></html></body>---------------upload result----------------<? session_start();$db=mysql_connect("localhost" ,"xxx","xxx");mysql_select_db("promotor",$db);$query="select * from members_music_uploads where name='$name' and id='$id'";$result=mysql_query($query);while($row=mysql_fetch_assoc($result)) {if($row["userfile_name"]=1) {echo "<b>Sorry you have a video already</b><br><br><a href='members_update_music_form.php'>Update music</a><br><br>";exit;}}$date_sent=date("d-m-y");if(!$userfile=="none") {echo"no file specified<br><br><br><br><a href='members_upload_music_form.php'>please try agin</a><br><br>";exit;}$uploaddir ="members_music/";$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);$size=$_FILES['userfile']['size'];$type=($_FILES['userfile']['type']=="audio/mpeg");if($size <= 320834100) {if($type) {if(move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile)) {$userfile_name=addslashes($userfile_name);$query="insert into members_music_uploads values('$id','$name','$date_sent','$userfile_name')";$result=mysql_query($query);echo "file uploaded";}else{echo"no file uploaded <br><br><br><a href='members_upload_music_form.php'>please try agin</a><br><br>";exit;}}else{echo"sorry wrong file type .mp3 only<br><br><br><a href='members_upload_music_form.php'>please try agin</a><br><br>";exit;}}?>---------------------get the music out--------------------------<?$music_query="SELECT * from members_music_uploads where id='$id'";$music_result=mysql_query($music_query);while($mus=mysql_fetch_assoc($music_result)) {$music_link="<embed src='members_music/".$mus["userfile_name"]."' bgcolor='#A0C0F0' width='125' height='125' autostart='false' loop='false' >";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14880-uploading-mp3s-to-database-or-server/#findComment-59602 Share on other sites More sharing options...
spires Posted July 17, 2006 Author Share Posted July 17, 2006 Thanks everyone, I'll go check it all out. :D Quote Link to comment https://forums.phpfreaks.com/topic/14880-uploading-mp3s-to-database-or-server/#findComment-59613 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.