Upload logic