little problem here.
it seems everything executes fine apart from the fact that the variable used to store the file seems to be empty.
where did this go wrong?
VXML:
<?xml version="1.0"?>
<vxml version="2.0">
<form>
<record name="myrecording" beep="true">
<prompt>
Please record a message after the beep.
</prompt>
<filled>
You just recorded the following message:
<value expr="myrecording"/>
Lets save this.
<submit next="upload.php" method="post" namelist="myrecording"/>
</filled>
</record>
</form>
</vxml>
PHP (5):
<?
header('Cache-Control: no-cache');
// Post variables
$myrecording = $_POST[myrecording];
file_put_contents("test.wav" ,$myrecording);
//
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
echo "<vxml version=\"2.0\">";
echo "<form id=\"main\">";
echo "<block>";
echo "Thank you";
echo "</block>";
echo "</form>";
echo "</vxml>";
?>
We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics
recording handover and PHP5
IVR code for file uploads in PHP
Hi,
You shouldn't use file_put_contents to do file uploads in PHP. Your PHP file should look more like this IVR code example. Note what's inside of the IVR <block> tags:
Keep in mind that the default media format of the file is "audio/basic", which means it's going to be a raw u-law media file. If you want to make your recorded file a .wav file, you should update your VXML to do so.
Hope this helps.
Regards,
Plum Support
You shouldn't use file_put_contents to do file uploads in PHP. Your PHP file should look more like this IVR code example. Note what's inside of the IVR <block> tags:
Code: Select all
<?php
echo "<?xml version=\"1.0\" encoding=\"latin-1\"?>";
?>
<vxml version="2.0">
<form>
<block>
<?php
if (isset($_FILES['myrecording']) && is_uploaded_file($_FILES['myrecording']['tmp_name'])) {
move_uploaded_file($_FILES['myrecording']['tmp_name'],"myrecording.wav");
unlink("temp.ul");
echo "<prompt bargein=\"false\">Audio file saved.</prompt>\n";
} else {
echo "<prompt bargein=\"false\">Audio not saved.</prompt>\n";
}
?>
</block>
</form>
</vxml>
Hope this helps.
Regards,
Plum Support
Last edited by support on Fri Feb 19, 2010 12:29 pm, edited 4 times in total.
Plum Support
http://www.plumvoice.com
http://www.plumvoice.com
-
- Posts: 16
- Joined: Mon Dec 10, 2007 6:33 am
IVR script change to play audio
Hi,
You need to format your audio file to be able to properly play it. In your VXML script, you would want to change this line of IVR code for the <record> tag:
to include this:
This will set the media format of the file to a .wav format instead of u-law raw format.
Hope this helps.
Regards,
Plum Support
You need to format your audio file to be able to properly play it. In your VXML script, you would want to change this line of IVR code for the <record> tag:
Code: Select all
<record name="myrecording" beep="true">
Code: Select all
<record name="myrecording" beep="true" type="audio/x-wav">
Hope this helps.
Regards,
Plum Support
Last edited by support on Wed Jan 13, 2010 12:20 pm, edited 4 times in total.
Plum Support
http://www.plumvoice.com
http://www.plumvoice.com
-
- Posts: 16
- Joined: Mon Dec 10, 2007 6:33 am