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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:44:04+00:00 2026-05-25T10:44:04+00:00

I’m trying to upload an image from my phone to a server. So I

  • 0

I’m trying to upload an image from my phone to a server. So I get the image uri and create a NameValuePair with it. I then use the following Android code to get a connection and upload the pic. This was taken from previous stackoverflow question(I would link but can’t find it even with Google…)

public void post(String url, List<NameValuePair> nameValuePairs) {

    HttpClient httpClient = new DefaultHttpClient();
    HttpContext localContext = new BasicHttpContext();
    HttpPost httpPost = new HttpPost(url);

    try {
           MultipartEntity entity = new  
                       MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);


             entity.addPart(nameValuePairs.get(0).getName(), new FileBody(new File(nameValuePairs.get(0).getValue())));
        Log.v("Uploading file",nameValuePairs.get(0).getValue());
        httpPost.setEntity(entity);
            HttpResponse response = httpClient.execute(httpPost);
           Log.v("Response", response.toString());
        } catch (IOException e) {
          e.printStackTrace();
        }
   }

On the server side I have the following code. This is PHP, which I am a complete novice at. I know there is no validation in the code, but I want to get the upload working before I start worrying about everything else.

      <?php

     if($_FILES){
           $name = $_FILES['image']['name'];
           move_uploaded_file($_FILES['image']['temp'],$name);

           echo "success!";
     }
    else {

  echo "Nothing uploaded";
   }
 ?>

Here the name of the NameValuePair is ‘image’, which is used as the file name.

Nothing gets uploaded, but a connection is made. Please help.

Following the request I put print_r($Files) in the code. The respons from the server was:

09-05 23:23:35.745: VERBOSE/Response(13849): Array

09-05 23:23:35.745: VERBOSE/Response(13849): (

09-05 23:23:35.745: VERBOSE/Response(13849):     [image] => Array

09-05 23:23:35.745: VERBOSE/Response(13849):         (

09-05 23:23:35.745: VERBOSE/Response(13849):             [name] => DSC_0100.jpg

09-05 23:23:35.745: VERBOSE/Response(13849):             [type] => 

09-05 23:23:35.745: VERBOSE/Response(13849):             [tmp_name] => /tmp/phpXcY8L1

09-05 23:23:35.745: VERBOSE/Response(13849):             [error] => 0


09-05 23:23:35.745: VERBOSE/Response(13849):             [size] => 806873

09-05 23:23:35.745: VERBOSE/Response(13849):         ) 09-05 23:23:35.745: VERBOSE/Response(13849): )

09-05 23:23:35.745: VERBOSE/Response(13849):**
  • 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-25T10:44:05+00:00Added an answer on May 25, 2026 at 10:44 am

    move_uploaded_file($_FILES[‘image’][‘temp’],$name); replace this line with

    move_uploaded_file($_FILES[‘image’][‘tmp_name’],$name);

    The file’s temporary file name is in “tmp_name”, as i can see from your log output.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported

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.