How to do multiple file uploads from a block's form? In the hook_block_configure of my block, I'm defining the form for my block.  I want it to have multiple file uploads, so I'm using "cardinality", but the following code isn't working for me.  I only get the one file field.

$form['background_image'] = array(
  '#type' =&gt; 'managed_file',
  '#title' =&gt; t('A Background Image'),
  '#description' =&gt; t('An image file.'),
  '#cardinality' =&gt; -1,
);


Any ideas?

I'm using Drupal 7.

Note: I don't want to just upload multiple files at once.  I want the user to be able to upload "one more file" or delete one of the existing ones.
I think the '#cardinality' it's not a form attribute, I couldn't find on the docs.

But I could find it on the field_multiple_value_form().

I suggest you to take another approach and use the AJAX framework, I found a couple of guides (guide_1 and guide_2) that might be helpful.