Fix some bugs on upload