[enc] Handle upload of duplicated file name
[httpserver] Clean up upload code and fix memory leaks.