Fix directory traversal

To prevent path like ../../../ using new File(...).getName() will extract the filename