Search code examples
delphiindydelphi-xe7

Indy FTP - Navigating to a certain folder from current folder


You never upload files in the root of an FTP folder. You always have a 'base' or 'remote' folder in which you work. In most cases this is 'public_html/domain.com'.

How to navigate to a specific folder from a random current folder without navigating all the way down to FTP root? Some kind of FTP.NavigateTo('downloads') which will always start the navigation from 'base' folder no matter where you are now.

I am asking this because navigating through few folders takes more time that uploading a HTML file!

What would be the most efficient way (navigation through as few folders as possible) of navigating?


Solution

  • You never upload files in the root of an FTP folder. You always have a 'base' or 'remote' folder in which you work. In most cases this is 'public_html/domain.com'.

    That is entirely dependent on the server's particular configuration. I've connected to (and written) FTP servers where the "root" folder is mapped to the logged in user's home directory on the server's filesystem, and thus uploading directly to the "root" is perfectly acceptable.

    How to navigate to a specific folder from a random current folder without navigating all the way down to FTP root?

    Simply provide an absolute path (relative to root) to TIdFTP.ChangeDir(). FTP allows both absolute and relative navigations.

    Some kind of FTP.NavigateTo('downloads') which will always start the navigation from 'base' folder no matter where you are now.

    FTP.ChangeDir('/downloads');