improved file upload error handling