Fix login func & write upload func