refixed dialog.dismiss() issues when uploading files