[Voiceglue] storing a recorded file in a periculer directory using voiceglue
pankaj pandey
pankaj.niet at yahoo.com
Mon May 10 16:21:54 UTC 2010
Hi Everyone,
i tried to store a recorded file using <record> tag and store it in the asterisk sound directory .
i tried it and submitting the recorded file to a php page but voiceglue shows a serious error has been occurred existing .
<?xml version="1.0"?>
<vxml version="2.0">
<form>
<script>
<![CDATA[
function makeCallAnalysisURL(MyCallerID,file)
{ return "http://127.1.0.0/upload.php?MyCallerID="+MyCallerID+"&file="+file+"; }
]]>
</script>
<record beep="true" name="file" type="audio/x-wav" maxtime="5s"
dtmfterm="true">
<prompt>
Say something. Press any key to stop recording.
</prompt>
<noinput>
I can't heard you.
</noinput>
<filled>
<prompt>
Your message <value expr="file" />
</prompt>
<script srcexpr="makeCallAnalysisURL(MyCallerID,file)"/>
<!--
<submit next="upload.php" method="post" namelist="file" enctype="multipart/form-data" />-->
</filled>
</record>
</form>
</vxml>
MY upload.php file is
<?
header('Cache-Control: no-cache');
include 'util.php';
$MAX_FILE_SIZE = 15000000;
$folder = "/tmp/";
$logfile = "log.txt";
// Post variables
$fname = $HTTP_POST_FILES['file']['name'];
$ftype = $HTTP_POST_FILES['file']['type'];
$fsize = $HTTP_POST_FILES['file']['size'];
$ftmp = $HTTP_POST_FILES['file']['tmp_name'];
//save log
$handler=fopen($folder.$logfile,"w");
fwrite($handler,the_file_name($fname));
fclose($handler);
if($fize > $MAX_FILE_SIZE){$error = 2;}
if(file_exists($folder."m_".$fname)){$error = 3;}
if(copy(the_file_name($fname),$ftmp."wav")) {$error = 0;}
switch($error){
case'0':
$mensaje="File saved Ok.";
break;
case'1':
$mensaje="Incorrect Format.";
break;
case'2':
$mensaje="File so Big.";
break;
case'3':
$mensaje="File already exists.";
break;
}
?>
and util.php is
<?php
function the_file_name($file){
$j=0;
$l=strlen($file);
for ($k=0;$k<=$l;$k++){
if (substr($file,$k,1)=='/'){
$j++;
if ($j==3){
return substr($file,$k);
}
}
}
return "";
}
?>
please help...
Thanks and Regards
Pankaj Pandey
+91-9990212758
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.voiceglue.org/pipermail/voiceglue/attachments/20100510/5bcc8c41/attachment.html>
More information about the Voiceglue
mailing list