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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:37:37+00:00 2026-06-07T00:37:37+00:00

im trying to do a file upload using http post but when I try

  • 0

im trying to do a file upload using http post but when I try to use a file from the micro-sd card on my phone, it doesn’t create it so that I can upload it. It works perfectly when selecting files from the main phone storage, just not the sd card.

Im using an external library for the file selection dialog, which returns this when I try to select an image from the sd card (in this example its a photo taken from the camera app):
/sdcard-ext/dcim/Camera/2012-07-02_12-28-19_548.jpg

This is returned from just a random image I found in the OS files on the phone:
/sdcard/DCIM/.thumbnails/1331049921270.jpg I know this one looks like its on an sd card too (or at least it does to me), but this is definitely the phone’s storage.

Here is the code I am currently using for the file upload:
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);

    HttpPost httppost = new HttpPost(myURL);

    MultipartEntity mp = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

    String mimeType = getFileMimeType(filePath);//the filePath is passed to the function
    that this code is contained inside and is initially sent from the file selection dialog
    mp.addPart("fileupload", new FileBody(new File(filePath), mimeType));

    httppost.setEntity(mp);

    String response = EntityUtils.toString( httpclient.execute( httppost ).getEntity(), "UTF-8" );
    System.out.println(response);

    httpclient.getConnectionManager().shutdown();

If any of could explain why this works for the phone’s internal storage and not the removable sd card, that would be great!
Thanks.

UPDATE: I’m targeting Android 2.2 if that makes any difference. If it doesn’t make any difference, I’m still targeting Android 2.2

  • 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-07T00:37:40+00:00Added an answer on June 7, 2026 at 12:37 am

    Add

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    

    Note: You should also see a “permission denied” error in the logcat, which should have alerted you to this problem.

    EDIT:
    Sorry, to just read from the external storage you need:

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to upload file on HTTP server using POST but when I
I'm trying to upload a file to the server using a HTTP multipart form
I was trying to upload file(s) using PrototypeJs request method but I failed. The
I'm trying to (HTTP) upload a binary file programmatically from within VBA. I intend
I'm trying to resume an upload using indy (HTTP Post), the code looks like
im trying to upload a file using org.apache.commons.fileupload. but i dont no, what mistake
I'm trying to do a simple file upload using objective c and NSUrlRequest. My
I am trying to upload file to an sharepoint online server using webclient. Up
I'm trying to upload a file using Watin and C#. Under Windows XP, Watin
I am trying to upload a file using commons-fileupload-1.1.1.jar file (I know it is

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.