I have created a file field with field_create_field() and added an instance of it to my custom node type with field_create_instance() in my module's hook_install()function. But how do I set it to allow unlimited file uploads. I can do it in the drupal interface by going to structure > content types > manage fields and clicking edit for my file field. I can set number of values on that page but how do I do it programmatically? There must some settings key I suppose but could not find it online.

I am using drupal 7.

1 Answer 1


my example, see "cardinality" value:

$field = array(
  'field_name' => 'field_ws_file', 
  'type' => 'file',

Instead of FIELD_CARDINALITY_UNLIMITED you could also simply use -1.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.