Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, Is it possible to allow users to upload a fixed number of files(3) but only upload one file at a time, so only allow them upload the second file when the first file has been successfully been uploaded.
Comments
Comment #1
nagarajanl CreditAttribution: nagarajanl commentedYou can specify the maximu value as 3 for the filefield and add a custom validator for the corresponding form which will trigger an error of we are trying to upload a second file in which the first file has not updated properly.
Check this url for more info http://drupal.org/node/546146
Comment #2
droid19 CreditAttribution: droid19 commentedThanks for the sharp response, However I would like to disable the other fields until the previous file has uploaded via JS.
Is it possible to know which part of the filefield.js is triggering the GET request or gets invoked on uploaded completion so I can disable/enable the 2 other fields.
Comment #3
nagarajanl CreditAttribution: nagarajanl commentedWhen you upload a filefield(lets say an image or a doc), automatically the preview wrapper with
So in your custom javascript just check whether the preview wrapper has displayed there for the first file field, if its there then enable the other 2 fields based on the same logic..
Comment #4
droid19 CreditAttribution: droid19 commentednice, didn't think of that. This means I have to poll, is it possible without polling?
Comment #5
nagarajanl CreditAttribution: nagarajanl commentedYeah..it is possible without polling...just look into the poll.module and see how the AHAH mechanism is implemented there..You can also do the same thing here...
Comment #6
droid19 CreditAttribution: droid19 commentedThanks nagarajanl. The below has done the trick for me. Anyone interested, just stick this in a js file and add it to the page using drupal_add_js in your form_alter implementation.
Comment #7
quicksketchSweet, thanks for the help nagarajanl.