Fixed file upload error handling.

Thanks to Daouda Kanoute for the report.