How do I restrict users with specific roles to upload files with specific extensions on node edit pages. On my site I have two specific roles editor and animator. Conditions are:
Editors can only upload .docx .doc .pdf files while Animators can upload .mp4 .mp3 .jpg files.
I added a validate function with
hook_form_alter() and the validate does work but the user has to save the entire form before validation spits out an error about the wrong file extension. I want to get the file extension as soon as the user has finished uploading their file and display the error message before submitting the form but after uploading the file.