Page 1 of 1

Code for uploading and previewing an audio file?

Posted: Mon Jun 08, 2009 9:26 am
by eatspinach
does anyone know where i might find a good tutorial on uploading and previewing an audio file.

i need to somehow keep the file in the database not sure if this is possible, i have never attempted anyhing like this before so i would love any help or advice on the topic.

so far i have written this code (not a lot but gives you the idea of what i am trying to achieve)

Code: Select all

 
<?php
 
    if (isset($_POST['uploadBtn'])) 
    {
        //save the mp3 or wav to the database
    }
    
    if (isset($_POST['playBtn'])) 
    {
        //play back the audio file that has just been uploaded
    }
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Play some Audio</title>
</head>
<body>
  <div style="margin:auto; width:50%;">
    <fieldset style="border:1px solid #7f9db9;">
      <legend>Upload Audio</legend>
      <input name="uploadBtn" type="file" />
      <input name="playBtn" value="Play" type="button"  />
    </fieldset>
  </div>
</body>
</html>
 
Thanks for your help in advance,
Dave

Re: Code for uploading and previewing an audio file?

Posted: Mon Jun 08, 2009 11:40 am
by jmyeom
... so you want to upload a play...?...


would you not upload using a save file script....(got it somewhere... ill dig it out for you!)
then when the page redirects after the upload, do a open file?....(easy to do :P)
then on page close = delete file from server?

Re: Code for uploading and previewing an audio file?

Posted: Tue Jun 09, 2009 4:42 am
by eatspinach
Well i guess the best way to do this would be that then the user hits play it plays the audio file that has been selected with the browse button.

Then when the form submit button is pressed the file is uploaded as a blob to the database, i have no idea how to do this so i would appreciate any help or direction.

Thanks,
Dave