0

Problem: Trying to upload bigger than ~ 50 mb files, $_FILES return empty array.

I try change limits on php (a lot of combination) but it useleass..

my class at java:

    public void upload() throws Exception {

        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(this.url);   

        try {

          FileBody bin = new FileBody(this.file);

          @SuppressWarnings("deprecation")
          MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
          reqEntity.addPart("file", bin);
          httppost.setEntity(reqEntity);

          System.out.println("Requesting : " + httppost.getRequestLine());
          ResponseHandler<String> responseHandler = new BasicResponseHandler();

          String responseBody = httpclient.execute(httppost, responseHandler);

          System.out.println("responseBody : " + responseBody);

        } catch (UnsupportedEncodingException e) {
          e.printStackTrace();
        } catch (ClientProtocolException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
        } finally {
          httpclient.getConnectionManager().shutdown();
        }
    }

my php code to print array for respawn:

<?php
ini_set('file_uploads', 1);
ini_set('max_file_uploads', '9999999999M');
ini_set('post_max_size', '2000M');
ini_set('max_input_time', 3600);
ini_set('max_execution_time', 3600);


 print_r($_FILES);
?>
Aseksas
  • 13
  • 4

2 Answers2

0

You could try to add the mime type of the file when you create the FileBody. For example:

FileBody bin = new FileBody(this.file, "application/octect-stream");

Another solution is to use the HttpURLConnection client that is easier to use and less error prone. Also, Google recommends to use it for new applications.

gere
  • 1,600
  • 1
  • 12
  • 19
0

One side or the other is breaking the http connection being used by the POST action.

Do you know which side ( client or server )

If you do not know , maybe you should try to rule out the server by using CURL to do the M-Multipart Post of one of your big ( +50 ) files.

Invoke CURL to upload and add the -v switch for verbose log so you can analyse the process.

Android POST action on files of 50 - 100 meg should work fine.

Since you are doing big uploads , you would want a client that you can send headers "expect 100 Continue" and where you can employ chunked transfer encoding along with a client side thread that can provide data to a buffer that is wrapped by something like a byteArrayEntity

apache or nginX on std config should handle this fine. If your php process is abending then maybe you need to check phpinfo.

Robert Rowntree
  • 6,230
  • 2
  • 24
  • 43