N
neil-holmquist
i have this code:
var parameters = "temp1=1"
http_request.onreadystatechange = saveHatHandler;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "multipart/form-data");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
where http_request is a valid XMLHttpRequest object.
my 'url' is a php file that has this for now:
<?php
$retval = phpversion();
$retval .= "<br>";
$retval .= print_r($_POST);
echo $retval;
?>
my handler just issues an alert with the result of
http_request.responseText
if i switch the Content-type to "application/x-www-form-urlencoded" it
works fine and the result i see is:
Array
(
[temp1]=> 1
)
4.4.2<br>1
if i switch the Content-type to "multipart/form-data" i see this:
Array
(
)
4.4.2<br>1
I eventually want to use this method for sending a file name to upload
to a DB so i need to use POST.
any ideas why this isn't working..i've looked all over for examples and
nothing i'm doing seems out of the ordinary..it just isn't working.
any help would be greatly appreciated..cause i'm about to pull out my
hair..haha
Thanks,
-neil.
var parameters = "temp1=1"
http_request.onreadystatechange = saveHatHandler;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "multipart/form-data");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
where http_request is a valid XMLHttpRequest object.
my 'url' is a php file that has this for now:
<?php
$retval = phpversion();
$retval .= "<br>";
$retval .= print_r($_POST);
echo $retval;
?>
my handler just issues an alert with the result of
http_request.responseText
if i switch the Content-type to "application/x-www-form-urlencoded" it
works fine and the result i see is:
Array
(
[temp1]=> 1
)
4.4.2<br>1
if i switch the Content-type to "multipart/form-data" i see this:
Array
(
)
4.4.2<br>1
I eventually want to use this method for sending a file name to upload
to a DB so i need to use POST.
any ideas why this isn't working..i've looked all over for examples and
nothing i'm doing seems out of the ordinary..it just isn't working.
any help would be greatly appreciated..cause i'm about to pull out my
hair..haha
Thanks,
-neil.