moved file upload code to seperate method
