Refactor fileupload

Turn the file uploader into a plugin, enabling easy reuse and the ability to use hooks like afterSubmit to add in extra functionality.