merged method from usermanager + fixed bug when upload file