在Android客户端,我已经为HTTP POST请求设置多PARAMS(我做 确保有Android客户端和我的web服务之间的连接。)墙身处理部分帕拉姆在PHP发布
的Android代码:
Content-Disposition: form-data; name="password" Content-Type: text/plain 123
Content-Disposition: form-data; name="username" Content-Type: text/plain tuyenpx
Content-Disposition: form-data; name="file"; filename="studio.png" Content-Type: image/png Content-Transfer-Encoding: binary
[ “此处的数据,已经写入的连接输出流”]
PHP代码:
if (isset($_GET['username'])) {
$userName = $_GET['username'];
}
if (isset($_GET['password'])) {
$passWord = $_GET['password'];
}
move_uploaded_file($_FILES['file']['filename'], "uploads/" . $_FILES['file']['filename']);
// if (!($userName == '' && $passWord == '')) {
$json = array("status" => TRUE, "username" => $userName,"password"=>$passWord);
header('HTTP/1.1 200 OK', true, 200);
response($json);
// } else {
// header('HTTP/1.1 400 Bad Request', true, 400);
// header('Content-type: text/plain; charset = UTF8');
// echo'invalid request , username or pass wo`enter code here`rd must not null';
问题:我错了,在PHP代码是什么,为什么$_GET['username']
总是返回null,我也尝试与$_POST['username']
,它也返回null。
谢谢你的帮助!
******************* Content-Disposition:form-data; name =“password” Content-Type:text/plain ******************* Content-Disposition:form-data; name =“username” Content-Type:text/plain tuyenpx ******************* Content-Disposition:form-data; NAME = “文件”;内容传输编码:二进制 [“这里的数据,已写入连接的输出流”] **********内容类型:image/png ********** ********* – user2669767
请发送Android代码,发送值,因为它似乎是一个问题在那里 – Brett
'Android代码:'。那不是代码。这是数据。我看不到任何界限。您已经提出了更好的代码。 – greenapps