Forum Moderators: coopster

Message Too Old, No Replies

Code for uploading and previewing an audio file?

         

eatspinach

3:35 pm on Jun 11, 2009 (gmt 0)

10+ Year Member



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)

<?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

jatar_k

3:38 pm on Jun 11, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld eatspinach,

I would change
//save the mp3 or wav to the database
to
//save the mp3 or wav to a directory and save the path/filename to the database

there are a ton of examples around about file uploads, you could start with php.net [php.net]

eatspinach

3:51 pm on Jun 11, 2009 (gmt 0)

10+ Year Member



ahh i see ok i will give that a go and i will let you know how i get on, thank you