[Multiple File Upload] Idea: add max files as an input
Forge component by Hugo Pinheiro
Application Type
Traditional Web

Would be great to set a limit of how many files can be uploaded feature, any way around this without modifying the component? 

@André Pinho :
You have to edit the "Private\JavaScriptNode" yourself:
With for example a variable 'MaxAmount' you can use this in the JavaScript.You cannot deny the end-user to select more files, but only prevent the upload of more than the maximum allowed:
You can for example change this:

if(filesProccessed == numberOfFiles){ //all files have been added to the JSON array

into:

if(filesProccessed == numberOfFiles || 
filesProccessed == MaxAmount 
){ //all files have been added to the JSON array

Also you have to prevent the 

reader.readAsDataURL(file);

to run when MaxAmount is reached.......


yes you can do.you can install the forge component in your environment and you can modify the component as per your requirement.

@André Pinho :
You have to edit the "Private\JavaScriptNode" yourself:
With for example a variable 'MaxAmount' you can use this in the JavaScript.You cannot deny the end-user to select more files, but only prevent the upload of more than the maximum allowed:
You can for example change this:

if(filesProccessed == numberOfFiles){ //all files have been added to the JSON array

into:

if(filesProccessed == numberOfFiles || 
filesProccessed == MaxAmount 
){ //all files have been added to the JSON array

Also you have to prevent the 

reader.readAsDataURL(file);

to run when MaxAmount is reached.......


Thanks both, I know this could be solved with JS, I guess this was a suggested approach to the component team to look into, rather than forking myself, or just in case I missed an obvious shortcut that avoided the modification of the component. Thank you for the detail Jeroen, maybe the component team can add this to their 'roadmap'.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.