moved the fileUploaded event emit higher in the code