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

  • SEARCH
  • Home
  • 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 9311985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:31:02+00:00 2026-06-19T01:31:02+00:00

I use this code that i found in some page but I only can

  • 0

I use this code that i found in some page but I only can upload images from my android application to the server and is working, but when i upload a video(.mp4) its saved as “file” like unknown.

public void upload() throws Exception {
    //Url of the server
    String url = "";
    HttpClient client = new DefaultHttpClient();
    HttpPost post = new HttpPost(url);
    MultipartEntity mpEntity = new MultipartEntity();
    //Path of the file to be uploaded
    String filepath = "";
    File file = new File(filepath);
    ContentBody cbFile = new FileBody(file);        

    //Add the data to the multipart entity
    mpEntity.addPart("image", cbFile);
    mpEntity.addPart("name", new StringBody("Test", Charset.forName("UTF-8")));
    mpEntity.addPart("data", new StringBody("This is test report", Charset.forName("UTF-8")));
    post.setEntity(mpEntity);
    //Execute the post request
    HttpResponse response1 = client.execute(post);
    //Get the response from the server
    HttpEntity resEntity = response1.getEntity();
    String Response=EntityUtils.toString(resEntity);
    Log.d("Response:", Response);
    //Generate the array from the response
    JSONArray jsonarray = new JSONArray("["+Response+"]");
    JSONObject jsonobject = jsonarray.getJSONObject(0);
    //Get the result variables from response 
    String result = (jsonobject.getString("result"));
    String msg = (jsonobject.getString("msg"));
    //Close the connection
    client.getConnectionManager().shutdown();
}

There is any way to make this work to upload videos too?

  • 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-06-19T01:31:03+00:00Added an answer on June 19, 2026 at 1:31 am

    There is not issue with this code works fine for upload videos and images, the problem was i´m missing the file extension in the name, so when the video was uploaded it should be NAME.EXTENSION not only NAME.

    NOTE:
    For all the people who is trying to upload a large(2MB-10GB) image or video to the server the only solution i found was encode the file in chunks and upload each chunk to the server, from there you only have to encode the chunks again. NO SIZE LIMITATION :)!!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to use code I've found that uses Win32. However, I'm getting this
this is my code that I write it but I want to use LINQ
I'm modifying some legacy code and I found a web page that loads the
I have this code that where I would normally use one line: if (tableView
hello I have this code that use to sort a datatable. Dim sortingIndex As
this is the code that I use to disable the button $(#btnSubmit).attr('disabled', 'disabled') $(#btnSubmit).disabled
It was suggested that I use this line of code to call an image
In code: //I know that to get this effect (being able to use it
i use this code in my app. just found is not correct when compare
I use this code to connect to SQL Server 2012, but it does not

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.