Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6388831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:19:42+00:00 2026-05-25T03:19:42+00:00

Hi I am uploadingfile to php server.For this we require to send string parameter

  • 0

Hi I am uploadingfile to php server.For this we require to send string parameter .I am using following code for uploading.So is there any tutorial that set parameter or any explanation that describes setting .thanks
url = new URL(httpPath);

    connection = (HttpURLConnection) url.openConnection();

    // Allow Inputs & Outputs
    connection.setDoInput(true);
    connection.setDoOutput(true);
    connection.setUseCaches(false);

    // Enable POST method
    connection.setRequestMethod("POST");

    connection.setRequestProperty("Connection", "Keep-Alive");
    connection.setRequestProperty("Content-Type",
            "multipart/form-data;boundary=" + boundary);

    outputStream = new DataOutputStream(connection.getOutputStream());
    outputStream.writeBytes(twoHyphens + boundary + lineEnd);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:19:43+00:00Added an answer on May 25, 2026 at 3:19 am

    Don’t reinvent the wheel. Use Apache HttpClient. Read this javadoc page for an example of a post containing a file upload and a string parameter:

      File f = new File("/path/fileToUpload.txt");
      PostMethod filePost = new PostMethod("http://host/some_path");
      Part[] parts = {
          new StringPart("param_name", "value"),
          new FilePart(f.getName(), f)
      };
      filePost.setRequestEntity(
          new MultipartRequestEntity(parts, filePost.getParams())
          );
      HttpClient client = new HttpClient();
      int status = client.executeMethod(filePost);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I using following code and it is successfully uploading files on my local machine.
I'm about uploading file to remote server using fsockopen() without using context. I'm able
I am using the ASIFormDataRequest for uploading file on server. I am using ASIHTTPRequest
I am uploading file(pdf for now) like this: (It is uploading content of file
I read something about this on PHP docs , but it's not clear to
I am uploading file to mainframe and before uploading when I open it using
I have a loop on the server ( C# ) that does this: for(i=0;i<=Request.Files.Count
I am using jQuery.Form to upload files on server. Here is an sample I
Files are being pushed to my server via FTP. I process them with PHP
Maybe this is a very silly question but I'm new using django. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.