Upload Image to server with multiple parameters

后端 未结 2 1430
情书的邮戳
情书的邮戳 2020-12-18 12:59

I\'m trying to upload Image to the Server, Which I have done and works very well. But the problem I\'m facing is I want to Upload Image as well as pass some parameter with t

相关标签:
2条回答
  • 2020-12-18 13:39

    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');
    
    0 讨论(0)
  • 2020-12-18 13:47

    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);
    
    0 讨论(0)
提交回复
热议问题