Jump to content


Photo

Uploading mp3s to database or server?


  • Please log in to reply
5 replies to this topic

#1 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 17 July 2006 - 07:25 PM

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

How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 17 July 2006 - 07:27 PM

Yes. Anything can be uploaded. I prefer to store the files in the OS, and the paths in the database.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 17 July 2006 - 07:29 PM

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
How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com

#4 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 17 July 2006 - 07:39 PM

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).
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 07:41 PM

example ok

---------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' >";
}

?>



Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 17 July 2006 - 08:00 PM

Thanks everyone, I'll go check it all out.

:D
How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users