在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