fix attachment function : auto mkdirs