我在android中的客户端设置了一些键值对,我怎样才能在服务器端获取它。
代码:
FileInputStream fileInputStream = new FileInputStream(sourceFile);
URL url = new URL(upLoadServerUri);
// Open a HTTP connection to the URL
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true); // Allow Inputs
conn.setDoOutput(true); // Allow Outputs
conn.setUseCaches(false); // Don't use a Cached Copy
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("ENCTYPE", "multipart/form-data");
conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
conn.setRequestProperty("uploaded_file", fileName);
conn.setRequestProperty("uploaded_file", fileName);
conn.setRequestProperty("key_1", "value_1");
conn.setRequestProperty("key_2", "value?_2");
conn.setRequestProperty("key_3", "value_3");
conn.setRequestProperty("key_n", "value_n");
如何在php中获取key_1,key_2 .... key_n。
我已经尝试过所有这些方式
$_GET['key_1'];
$_REQUEST['key_1'];
$_POST['key_1'];
$_FILE['key_1'];
所有这些都不适合我,
请伙计们帮帮我。答案 0 :(得分:1)
这些是标题,而不是发布或获取值。 您可能需要从$ _SERVER ['']
中阅读它们或者也查看这篇文章 How do I read any request header in PHP