Fix upload function