Added flush() at the end of file upload