diff --git a/packages/nodes-base/nodes/Ftp.node.ts b/packages/nodes-base/nodes/Ftp.node.ts index dacbd40a5d..71a864bd02 100644 --- a/packages/nodes-base/nodes/Ftp.node.ts +++ b/packages/nodes-base/nodes/Ftp.node.ts @@ -348,13 +348,11 @@ export class Ftp implements INodeType { const remotePath = this.getNodeParameter('path', i) as string; // Check if dir path exists - const dirExists = await sftp!.exists(dirname(remotePath)); + const dirPath = dirname(remotePath); + const dirExists = await sftp!.exists(dirPath); // If dir does not exist, create all recursively in path if (!dirExists) { - // Separate filename from dir path - const fileName = basename(remotePath); - const dirPath = remotePath.replace(fileName, ''); // Create directory await sftp!.mkdir(dirPath, true); }