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 8270715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:39:55+00:00 2026-06-08T06:39:55+00:00

Good day! I am trying to search for a basic tutorial of uploading an

  • 0

Good day! I am trying to search for a basic tutorial of uploading an image file from Android to an online MySQL database, but I can’t find any.

I am now making an activity that can upload a user’s profile picture from the Android to the online server.

What I need is like displaying a button and when it’s clicked, a user can choose an image from the files. Can someone guide me on doing this? Thanks in advance!

  • 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-08T06:39:58+00:00Added an answer on June 8, 2026 at 6:39 am

    On the Client Side,You can Do this.

    HttpURLConnection connection = null;
    DataOutputStream outputStream = null;
    DataInputStream inputStream = null;    
    
    String pathToOurFile = "path of the image.jpeg";
    String urlServer = "http://xxx.xxx.xxx.xxx/uploader.php";
    String lineEnd = "\r\n";
    String twoHyphens = "--";
    String boundary =  "*****";
    
    int bytesRead, bytesAvailable, bufferSize;
    byte[] buffer;
    int maxBufferSize = 1*1024*1024;
    
    try {
            FileInputStream fileInStream = new FileInputStream(new File(pathToOurFile) );
    
            URL url = new URL(urlServer);
            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);
            outputStream.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + pathToOurFile +"\"" + lineEnd);
            outputStream.writeBytes(lineEnd);
    
            bytesAvailable = fileInStream.available();
            bufferSize = Math.min(bytesAvailable, maxBufferSize);
            buffer = new byte[bufferSize];
    
            // Read file
            bytesRead = fileInStream.read(buffer, 0, bufferSize);
    
            while (bytesRead > 0)
            {
                outputStream.write(buffer, 0, bufferSize);
                bytesAvailable = fileInStream.available();
                bufferSize = Math.min(bytesAvailable, maxBufferSize);
                bytesRead = fileInStream.read(buffer, 0, bufferSize);
            }
    
            outputStream.writeBytes(lineEnd);
            outputStream.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
    
            // Responses from the server (code and message)
            serverResponseCode = connection.getResponseCode();
            serverResponseMessage = connection.getResponseMessage();
    
            fileInputStream.close();
            outputStream.flush();
            outputStream.close();
        }
        catch (Exception ex)
        {
            //Exception handling
        }
    

    Server side

    <?php
        $target_path  = "./";
        $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
        if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
             echo "Success";
        } else{
            echo "Error";
        }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day, I have a question here. I am trying to fetch image from
Good day. I'm new to C# and trying to call functions from a DLL
Good day! I'm trying to implement drop down menu from examples on my site.
Good day! I am trying to output a JPG file contained in the web
Good day, friends. Once again stupid question about Obj-C from newbie :) I'm trying
Good day Im trying to implement a read/write privilege in a folder but no
Good day, I'm trying to convert my site from ANSI-encoded PHP files to UTF-8.
Good day. I'm trying to make an online quiz application using php. The idea
Good day! I am currently trying to create a background-image with multiple images on
Good day, I'm trying some examples to classify text from the NLTK cookbook and

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.