[#677] Fix resource leak during fileupload