improve robustness of file upload