Refactoring and html5 upload