سؤال

I am setting some key value pair at client side in android, how can i get it at server side.

code:

               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"); 

how can get key_1,key_2 .... key_n in php.

i have tried all these way

$_GET['key_1'];
$_REQUEST['key_1'];
$_POST['key_1'];
$_FILE['key_1'];

all of these are not working for me,

please guys help me.

هل كانت مفيدة؟

المحلول

these are headers, not post or get values. you may need to read them from $_SERVER['']

or check this post too How do I read any request header in PHP

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top