大家帮我看一下是什么问题?
php只返回“用户名”,但"aaa"显示收不到、显示不了。
因为还要传输图片base64的数据,所以要用post方式。vbSet HttpClient = CreateObject("Microsoft.XMLHTTP")
HttpClient.Open "POST", "http://127.0.0.1/test.php", False
HttpClient.setRequestHeader "Content-Type", "text/xml; charset=gb2312"
HttpClient.send "f_name=aaa&f_code=123456"<?php
//强制浏览器编码
@header('Content-type: text/html;charset=gb2312');//设置时区
date_default_timezone_set('PRC');
$s_name = trim($_POST['f_name']);
$s_code = $_POST['f_code'];echo "用户名" . $s_name;
?>
php只返回“用户名”,但"aaa"显示收不到、显示不了。
因为还要传输图片base64的数据,所以要用post方式。vbSet HttpClient = CreateObject("Microsoft.XMLHTTP")
HttpClient.Open "POST", "http://127.0.0.1/test.php", False
HttpClient.setRequestHeader "Content-Type", "text/xml; charset=gb2312"
HttpClient.send "f_name=aaa&f_code=123456"<?php
//强制浏览器编码
@header('Content-type: text/html;charset=gb2312');//设置时区
date_default_timezone_set('PRC');
$s_name = trim($_POST['f_name']);
$s_code = $_POST['f_code'];echo "用户名" . $s_name;
?>
HttpClient.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<?php
//强制浏览器编码
@header('Content-type: text/html;charset=gb2312');
//设置时区
date_default_timezone_set('PRC');
$s_name = trim($_POST['f_name']);
$s_code = $_POST['f_code'];
echo "用户名" . $s_name;
?></body>
</html>
而且要注意你的PHP配置,default_charset = "gb2312"
HttpClient.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=gb2312"
Public Function URLEncode(ByVal strParameter As String) As String
Dim s As String
Dim I As Integer
Dim intValue As Integer
Dim TmpData() As Byte
s = ""
TmpData = StrConv(strParameter, vbFromUnicode)
For I = 0 To UBound(TmpData)
intValue = TmpData(I)
If (intValue >= 48 And intValue <= 57) Or _
(intValue >= 65 And intValue <= 90) Or _
(intValue >= 97 And intValue <= 122) Then
s = s & Chr(intValue)
ElseIf intValue = 32 Then
s = s & "+"
Else
s = s & "%" & Hex(intValue)
End If
Next I
URLEncode = s
End Function
第四行代码改成HttpClient.Send "f_name=" & URLEncode("中文") & "&f_code=123456"