refine file upload method