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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:16:02+00:00 2026-06-07T06:16:02+00:00

I am currently trying to upload file / images on to my apache server

  • 0

I am currently trying to upload file / images on to my apache server from AVD. I’m not getting any errors when i execute my code, but image is not uploaded to the server. I’ve changed permission of the folder on the apache server which is
http://10.0.2.2/images to writable and editable by other users. I am having trouble with this, please help. Follow is my code

This code gets the image and decode into bitmap.

   bmp = BitmapFactory.decodeFile(filePath);

Following is code that i run to upload files to the server

ByteArrayOutputStream bos = new ByteArrayOutputStream();
Bitmap tmpbmp = bmp;
tmpbmp.compress(CompressFormat.JPEG, 75, bos);
byte[] data = bos.toByteArray();
HttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost(url);
ByteArrayBody bab = new ByteArrayBody(data, "test.jpg");
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("uploaded", bab);
reqEntity.addPart("photoCaption", new StringBody("aaaa"));
postRequest.setEntity(reqEntity);
HttpResponse httpResponse = httpClient.execute(postRequest);
BufferedReader reader = new BufferedReader(new  InputStreamReader(httpResponse.getEntity().getContent(), "UTF-8"));
String sResponse;
StringBuilder s = new StringBuilder();

            while ((sResponse = reader.readLine()) != null) {
                s = s.append(sResponse);
            }

            Log.i("wi", "Response: " + s);

        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            Log.i("wi", "Encoding failed: " + e);
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            Log.i("wi", "client protocol exception!: " + e);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            Log.i("wi", "IO Exception!: " + e);
        }

And i am getting response from Log.i(“wi”, “Response: ” + s); =

    Response: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html> <head>  
<title>Index of /images</title> </head> <body><h1>Index of /images</h1><ul><li><a 
href="/"> Parent Directory</a></li></ul></body></html>

It hasn’t uploaded the file.

  • 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-07T06:16:03+00:00Added an answer on June 7, 2026 at 6:16 am

    I am using Apache’s commons-net-ftp library to upload my song file to the server…i am giving you the code….Try using this..

     import java.io.File;
    
        import java.io.FileInputStream;
    
        import java.io.IOException;
    
        import org.apache.commons.net.ftp.FTP;
    
        import org.apache.commons.net.ftp.FTPClient;
    
        import android.util.Log;
    
    
    
        public class MyOwn {
    
            public void goforIt(){
    
    
                FTPClient con = null;
    
                try
                {
                    con = new FTPClient();
                    con.connect("www.mysamle.net");                 // Its dummy Address
    
                    if (con.login("uju495", "Stevejobs!!"))
                    {
                        con.enterLocalPassiveMode();                   // Very Important
    
                        con.setFileType(FTP.BINARY_FILE_TYPE);        //  Very Important
                        String data = "/sdcard/Vivekm4a.m4a";
    
                        FileInputStream in = new FileInputStream(new File(data));
                        boolean result = con.storeFile("/Ads/Vivekm4a.m4a", in);
                        in.close();
                        if (result) Log.v("upload result", "succeeded");
                        con.logout();
                        con.disconnect();
                    }
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }   
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to upload a csv file to a database through simple html
i am currently trying to add a uploading/scanning screen to my file upload site,
Im currently trying to downlaod a audio track from a WCF, i need some
I am currently trying to write some code that will accept some FTP details,
I'm trying to get a file upload progress bar working in a rails 3
I am trying to save an uploaded image from an iPhone to a server
Having submitted a form with a file to upload, I'm having trouble trying to
There are plenty of multipart/form-data file upload solutions out there, but I have not
I am currently trying to use Miles J plugin located here http://milesj.me/code/cakephp/uploader Although I
I am trying to upload an image to the server (with a path in

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.