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

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

The Archive Base Latest Questions

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

I’m having trouble setting up the HTTP Post android app code to upload a

  • 0

I’m having trouble setting up the HTTP Post android app code to upload a file, string, or byte array to CherryPy. Can someone point me in the right direction?

I get HTTPError: (404, ‘Missing parameters: myFile’).
CherryPy code:

       html += """            <h2>Upload a file</h2>
        <form action="upload" method="post" enctype="multipart/form-data">
        filename: <input type="file" name="myFile" /><br />
        <input type="submit" />
        </form></body></html>"""

def upload(self, myFile):
    out = """<html>
    <body>
        myFile length: %s<br />
        myFile filename: %s<br />
        myFile mime-type: %s
    </body>
    </html>"""

    size = 0
    f = open(myFile.filename, 'w')
    while True:
        data = myFile.file.read(8192)
        if not data:
            break
        size += len(data)
        f.write(data)

    return out % (size, myFile.filename, myFile.content_type)
upload.exposed = True

Android app code:

              String writeOut = "1,1234,4567,8910";
              byte[] byteArray = writeOut.getBytes();

              File tmpFile = new File("/sdcard/Download/tst.txt");

              HttpParams params = new BasicHttpParams(); 
              params.setParameter("myFile", "myfile1");
              HttpConnectionParams.setConnectionTimeout(params, 15000); 
              HttpConnectionParams.setSoTimeout(params, 5 * 60 * 1000); 
              HttpClient client = new DefaultHttpClient(params); 
              HttpPost  post = new HttpPost("http://192.168.1.123:8080/upload"); 
              HttpEntity requestEntity = new FileEntity(tmpFile, "multipart/form-data;boundary=--");
              post.setEntity(requestEntity); 
              HttpResponse response = (HttpResponse) client.execute(post); 
              int statusCode = response.getStatusLine().getStatusCode();
              HttpEntity entity = response.getEntity();
              String page = EntityUtils.toString(entity);
              Log.d(HTTPTAG, "reply: " + page);
              Log.d(HTTPTAG, "statuscode: " + statusCode);

Logs
CherryPy side:

192.168.1.114 - - [01/Aug/2012:10:10:25] "POST /upload HTTP/1.1" 404 1265 "" ""  

Logcat side:

D/MyApp.HTTP( 6966): reply: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
D/MyApp.HTTP( 6966): "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
D/MyApp.HTTP( 6966): <html>
D/MyApp.HTTP( 6966): <head>
D/MyApp.HTTP( 6966):     <meta http-equiv="Content-Type" content="text/html;     charset=utf-8"></meta>
D/MyApp.HTTP( 6966):     <title>404 Not Found</title>
D/MyApp.HTTP( 6966):     <style type="text/css">
D/MyApp.HTTP( 6966):     #powered_by {
D/MyApp.HTTP( 6966):         margin-top: 20px;
D/MyApp.HTTP( 6966):         border-top: 2px solid black;
D/MyApp.HTTP( 6966):         font-style: italic;
D/MyApp.HTTP( 6966):     }
D/MyApp.HTTP( 6966): 
D/MyApp.HTTP( 6966):     #traceback {
D/MyApp.HTTP( 6966):         color: red;
D/MyApp.HTTP( 6966):     </style>
D/MyApp.HTTP( 6966): </head>
D/MyApp.HTTP( 6966):     <body>
D/MyApp.HTTP( 6966):         <h2>404 Not Found</h2>
D/MyApp.HTTP( 6966):         <p>Missing parameters: myFile</p>
D/MyApp.HTTP( 6966):         <pre id="traceback">Traceback (most recent call     last):
D/MyApp.HTTP( 6966):   File "/usr/local/lib/python2.7/dist-packages/CherryPy-3.2.2-py2.7.egg/cherrypy/_cprequest.py", line 656, in respond
D/MyApp.HTTP( 6966):     response.body = self.handler()
D/MyApp.HTTP( 6966):   File "/usr/local/lib/python2.7/dist-packages/CherryPy-3.2.2-py2.7.egg/cherrypy/lib/encoding.py", line 188, in __call__
D/MyApp.HTTP( 6966):     self.body = self.oldhandler(*args, **kwargs)
D/MyApp.HTTP( 6966):   File "/usr/local/lib/python2.7/dist-packages/CherryPy-3.2.2-py2.7.egg/cherrypy/_cpdispatch.py", line 40, in __call__
D/MyApp.HTTP( 6966):     raise sys.exc_info()[1]
D/MyApp.HTTP( 6966): HTTPError: (404, 'Missing parameters: myFile')
D/MyApp.HTTP( 6966): </pre>
D/MyApp.HTTP( 6966):     <div id="powered_by">
D/MyApp.HTTP( 6966):     <span>Powered by <a href="http://www.cherrypy.org">CherryPy 3.2.2</a></span>
D/MyApp.HTTP( 6966):     </div>
D/MyApp.HTTP( 6966):     </body>
D/MyApp.HTTP( 6966): </html>
D/MyApp.HTTP( 6966): statuscode: 404
  • 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-08T22:57:41+00:00Added an answer on June 8, 2026 at 10:57 pm
    HttpConnectionParams.setConnectionTimeout(params, 15000); 
    HttpConnectionParams.setSoTimeout(params, 5 * 60 * 1000); 
    
    HttpParams params = new BasicHttpParams(); 
    params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    
    HttpClient client = new DefaultHttpClient(params);
    HttpPost post = new HttpPost("http://192.168.1.123:8080/upload"); 
    
    File tmpFile = new File("/sdcard/Download/tst.txt");
    MultipartEntity mpEntity = new MultipartEntity();
    mpEntity.addPart("myFile", new FileBody(tmpFile, "text/plain"));
    post.setEntity(mpEntity); 
    
    HttpResponse response = (HttpResponse) client.execute(post); 
    int statusCode = response.getStatusLine().getStatusCode();
    HttpEntity entity = response.getEntity();
    String page = EntityUtils.toString(entity);
    Log.d(HTTPTAG, "reply: " + page);
    Log.d(HTTPTAG, "statuscode: " + statusCode);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am using Paperclip to handle profile photo uploads in my app. They upload
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.