1. fix bug when directory is empty. 2. add file reupload when last upload is fail