I need to save a wav file that is HTTP POSTed to a php page.
What does PHP5 do automatically to a POSTed variable when it puts it in
the $_POST[] superglobal array? I haven't been able to find any info on
this....
I have a script that does what I want in PERL, but I need to do it in
PHP.
I think the PERL does something magic when it does this:
#### PERL CODE ####
read ( STDIN, $buffer, $ENV { 'CONTENT_LENGTH ' } );
@pairs = split ( /&/, $buffer );
foreach $pair ( @pairs )
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM { $name } = $value;
}
#### END PERL CODE ####
This is where it separates out the name,value pairs, and for the value,
does the equivalent of urldecode(), base64decode() (am I correct?)
It looks like PHP5 is automatically doing base64decode() and
urldecode(), because when I look at the raw tcpdump of the HTTP
session, I see this:
POST.<obscured>/save_wav.php.HT TP/1.0..
Content-Type:.applicati on/x-www-form-urlencoded..
User-Agent:.BeVocal/2.7.VoiceXML/2.0.BVPlatform/1.8.5.rc1a..
Host:.<obscured >..
Content-Length:.147341. .
Via:.1.1.bvcapx y002:8080.(squi d/2.5.STABLE4)..
X-Forwarded-For:.10.0.121.2 15..
Cache-Control:.max-age=0..
Connection:.kee p-alive..
...
message=RIFF%E4 %C6%00%00WAVEfm t+%10%00%00%00% 01%00%01%00
(90K more of this follows)
But when I look at the data as $_POST['message'], I see this:
RIFFt\0\0WAVEf mt \0\0\0\0\0@ \0\0@\0\0\0\ 0\0\0dataîs\0\0 ÿ
the + was translated to " " and the %NN was translated back to normal
value.
So, my question is, if PHP5 is doing base64decode and urldecode
automatically, why is my data still coming across corrupt?
Here is how I'm trying to save it:
// PHP CODE
$writepath=<som e path>;
$filename="wavf ile";
$wavdata=$_POST["message"];
$lpn=$_POST["license_plate_ number"];
$callerid=$_POS T["callerid"];
file_put_conten ts("$writepath/$filename-raw.wav", "$wavdata") ;
file_put_conten ts("$writepath/$filename-u.wav", urldecode($wavd ata));
// exactly same as raw file
// END PHP CODE
This writes all the data to a file, and I see the wav header, but the
data doesn't look right when I compare it to the output from the PERL
script (i'm not sure if visually comparing two wav files get me
anything)
Is there another way I should be saving this besides
file_put_conten ts()?
Background info:
I have a voicexml app that sends three things to my php page:
callerid (string)
license_plate_n umber (string)
message (wav data)
I have no problem accessing:
$_POST["callerid"]
$_POST["license_plate_ number"]
My voiceXML app sends the wav data as "audio/wav", and the enctype is
"applicatio n/x-www-form-urlencoded"
I've been searching all over the internet for the past few days and I'm
stuck.
help, please?
Billy Becker 14 4337
More Info:
a hex dump of the wav file from perl shows lots of 0x00 when there is
silence, but a hex dump from php shows lots of this pattern 5C 30 F8 FF
F8 FF F8 FF F8 FF F8 FF 08 where there should be silence in the file.
any ideas what php is doing (or what I'm making php do?)
--
Billy
I'm not using a file input control. Right now, the data is sent:
Content-Type:.applicati on/x-www-form-urlencoded..
This method works with PERL, and I would like to make it work with PHP.
I can see the data in PHP, but the format is wrong, and I was wondering
what PHP does to POST variables before putting them in the $_POST[]
array. I see that it is urldecoding and base64decoding. .. but it must
be doing something else in addition, because my data is corrupt. As the
snippet of hex data from my previous post shows, PHP is turning
changing 00 into high-bit characters. Is this a bug? or is this
intended functionality that just isn't explained anywhere?
Another question: is there any way to access the raw POST data? if so,
how?
Thanks,
Billy
I'm not using a file input control. Right now, the data is sent:
Content-Type:.applicati on/x-www-form-urlencoded..
This method works with PERL, and I would like to make it work with PHP.
I can see the data in PHP, but the format is wrong, and I was wondering
what PHP does to POST variables before putting them in the $_POST[]
array. I see that it is urldecoding and base64decoding. .. but it must
be doing something else in addition, because my data is corrupt. As the
snippet of hex data from my previous post shows, PHP is turning
changing 00 into high-bit characters. Is this a bug? or is this
intended functionality that just isn't explained anywhere?
Another question: is there any way to access the raw POST data? if so,
how?
Thanks,
Billy
On 2005-05-10, bi**********@gm ail.com <bi**********@g mail.com> wrote: Another question: is there any way to access the raw POST data? if so, how?
Afaik it's only possible if php doesn't recognize the content-type.
And you should be able to read like $file = file_get_conten ts('php://input');
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
On 2005-05-10, bi**********@gm ail.com <bi**********@g mail.com> wrote: Another question: is there any way to access the raw POST data? if so, how?
Afaik it's only possible if php doesn't recognize the content-type.
And you should be able to read like $file = file_get_conten ts('php://input');
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
I just discoverd the "always_populat e_raw_post_data = on" directive
that you can add to the php.ini file. With that in place, I am able to
get to the $HTTP_RAW_POST_ DATA string, and see my values. From here, I
just need to parse the string, and then urldecode() and base64decode()
the part I want.
It's a hassle, but atleast I'll get to what I want.
Still would like to know what exactly PHP5 does when it stick variables
in the $_POST[] array...
--
Billy This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Pedro Fonseca |
last post by:
Greetings everyone!
I'm porting everything to PHP5. I have session variables in all of my
web application. Until PHP5 I was using session variables like:
if ($_SESSION == 'Bar') {
$value = 5;
}
$_SESSION is of course set on some other script. But this now
|
by: Mike |
last post by:
I am sure that I am making a simple boneheaded mistake and I would
appreciate your help in spotting in. I have just installed
apache_2.0.53-win32-x86-no_ssl.exe
php-5.0.3-Win32.zip
Smarty-2.6.7.tar.gz
on a system running WindowsXP SP2.
Apache and PHP tested out fine. After adding Smarty, I ran the
following http://localhost/testphp.php
|
by: brian_mckracken |
last post by:
This might not be the right group for this question, since its kind of
a pure html question...
Given the html construct:
<form action='index.php?expand=0,10000' method='post'>
Email: <input type='text' name='login' size='30'/>
Password:<input type='password' name='login' size='30'/>
</form>
|
by: will.lai |
last post by:
Hi: Just learning PHP and couldn't get access to the $_POST variables
from a form. Here are my code sniplets below. For the life of me I
can't figure out why the POST variables aren't being passed. FYI, if I
switch the method to GET and the $_GET variable works great.
Here's the feedback.html:
<html>
<head><title>Feedback form</title></head>
<body>
|
by: Chuck Anderson |
last post by:
I have finally started coding with register_globals off (crowd roars -
yeay!).
This has created a situation that I am not sure how I should handle. I
have scripts (pages) that can receive an input variable from the POST
array (initial entry) or it could be in the GET array (go back and
re-edit a form, for instance.)
In my old sloppy scripting days this was no problem, as I had
register_globals on and would merely access the the input...
| |
by: mickey |
last post by:
I am trying to post an array using cURL from one PHP page to another. I
can't figure out how to correctly post and read the array on the page
that actually receives it. Here is what I have...
$session = curl_init();
curl_setopt( $session, CURLOPT_URL,
"https://www.myswebsite.com/receiving.php" );
curl_setopt( $session, CURLOPT_HEADER, false );
curl_setopt( $session, CURLOPT_POST, true );
|
by: dirk |
last post by:
Hello,
As beginner, I'm a bit confused by passing 2 variables using a html-form
with method=POST. If passing one of them, it works ; if passing both
together, nope. At least when I reload the same page by using
$_SERVER in an included file (inc.php) it doesn't work.
Referring to another "page.php" is succesfull. Also passing both variables
with the GET-method works. Can somebody help me please ?
Thank you,
|
by: The Big One |
last post by:
8-7-2008
Hello,
Our hosting provider has changed his server to PHP5.
I have a PHP file that normaly gives the custumor an email, and i get one mail.
Now the server has changed i only get my email, but the custumor gets nothing.
Who can help me to change this PHP file to PHP5 ?????
|
by: Jerry Stuckle |
last post by:
incredibody@gmail.com wrote:
<Lots of code snipped>
In their upgrade, they turned off register_globals - which is a good thing.
Since you are posting your form, you need to look in the $_POST array
for the values, i.e. instead of
if ($op != "ds") {
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |