This can be done by putting something like that in the upload_js():

if (variable_get('upload_max_number_of_file', 1)==sizeof($node->files))
  unset($form['new']);

This solutions is "nice" as it will not display any error, the user simple can't attach more file as there will be no controls on the form for that ;-)

This is just an idea but I need such a feature.
Thank you

Comments

MrPrise’s picture

My previous hack was not correct. Here is a better one ;-)

In the function _upload_form() the line if (user_access('upload files')) {
should be changed to
if ((user_access('upload files')) && (variable_get('upload_max_number_of_file', 1)>sizeof($node->files))) {

MrPrise’s picture

Just one more think. This limit will be more powerful if we can specify the limit per content type.
The ability to hide the file's description field would be nice too.

marcingy’s picture

Status: Active » Fixed

Fixed as filefield is now in core and allows for limits.

marcingy’s picture

Status: Fixed » Closed (fixed)