Fix bug with conditional styling through angular and cleaned up code

Fixes:
 - Fixed problem with conditional styling of HTML through Angular controller
 - Cleaned up upload code - separated into two functions
 - Fixed bug that caused number of files variable to increment at wrong time