What's wrong with my plupload implementation? For reasons that are out of scope here I should not send packets over 32 MB, so my php.ini looks like this:

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 500M

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 32M


I know plupload can do this, so I "only" needed to integrate it with Drupal. For this I installed Plupload integration module. Thanks to Clive I found this bug report: 


  Right now you need to spesify a max file size larger than the max post size as plupload is stil honoring the setting. 


I'm not particularly happy with upload_max_filesize = 500M but I guess for now I can live and work with it.

I tried custom code first:

  'DownloadFile' =&gt; array(
    //'#type' =&gt; 'managed_file',
    '#type' =&gt; 'plupload',
    '#title' =&gt; t("Download"),
    '#title_display' =&gt; 'invisible',

    '#upload_validators' =&gt; array(
      'file_validate_extensions' =&gt; array(),
      'file_validate_size' =&gt; array(variable_get('my_max_file_size', 300 * 1024 * 1024)),
    ),
    '#upload_location' =&gt; 'public://mymodule/download',
    '#default_value' =&gt; $item-&gt;fid,
    '#required' =&gt; TRUE,
    '#plupload_settings' =&gt; array(
      'runtimes' =&gt; 'html5',
      'chunk_size' =&gt; '10mb',
    ),
  ),


It was showing 300MB under the Form API field all right. Sadly, everything over 20MB gave me:


  Error: File too large: Some_182MB_file.zip


So I thought I'm doing something wrong and decided to try ready-made solution. I went for FileField Sources Plupload - I see 32 MB on the node add form, but 182 MB file uploaded all right.

So what's wrong with my implementation? I practically copied example from official documentation so I would expect it to work.
When using Plupload integration module in custom code, you need to set up size twice. Preferably to the same value. First place you do it is the usual:

'#upload_validators' =&gt; array(
  'file_validate_size' =&gt; array(variable_get('my_max_file_size', 300 * 1024 * 1024)),
),


This handles display and post-upload verification.

Second place is #plupload_settings:

'#plupload_settings' =&gt; array(
  'runtimes' =&gt; 'html5',
  'chunk_size' =&gt; '10mb',
  'max_file_size' =&gt; variable_get('my_max_file_size', 300 * 1024 * 1024) . 'b',
),


This is what actually goes to the plupload JavaScript.