Upload Image to server with multiple parameters

青春壹個敷衍的年華 提交于 2019-11-29 08:32:04

I have done this recently with PHP CodeIgniter:

Android Side:

/*** POST THIS CODE AFTER
dos = new DataOutputStream(conn.getOutputStream()); 
***/

dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name=mobile_no" + lineEnd); // name=mobile_no so you have to get PHP side using mobile_no
dos.writeBytes(lineEnd);
dos.writeBytes(mobile_number); // mobile_no is String variable
dos.writeBytes(lineEnd);

PHP Side (Core PHP):

$mobile_no = $_POST['mobile_no'];

PHP Side (Using CodeIgniter Framework):

$mobile_no => $this->input->post('mobile_no');

Try this:

$mobileNumber = $_POST['userNumber']; // get mobile number from post

Since you are using POST method:

conn.setRequestMethod("POST");

And setting mobile number as:

conn.setRequestProperty("userNumber", usernumber);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!