Jump to content

FTP Directory Help Splitting Current Directory


Danny620

Recommended Posts

Good Afternoon,

 

I'm building a FTP script that will connect to an ftp server list the current directory, then you can click into folders like a folder tree like "/ssr/Sale/Commission/2018/". I have a varible that logs the current folder your in, what I would like to do is split a string like "/ssr/Sale/Commission/2018/" into urls like below.

 

/ssr/Sale/Commission/

 

/ssr/Sale/

 

/ssr/

 

So when I user clicks the links it can move up the folder root like if they are in commisions folder there can be a link to take them back to sales or if they want to jump right back to ssr. How can I do this?

Link to comment
Share on other sites

:psychic:

 

What is $ftpObj? What is getCurrentDir? Where are those from? I don't know.

 

Read the docs for dirname() to understand what it does and how to use it, then figure out what you have to do to fit it into your code.

Link to comment
Share on other sites

public function getCurrentDir()
    {
        if($this->currentDir == '/ssr') {
            return '/ssr/';
        }

        return $this->currentDir . '/';
    }

 

public function changeDir($directory)
    {
        if (ftp_chdir($this->connectionId, $directory)) {
            $this->logMessage('Current directory is now: ' . ftp_pwd($this->connectionId));
            $this->logCurrentDir(ftp_pwd($this->connectionId));
            return true;
        } else {
            $this->logMessage('Couldn\'t change directory');
            return false;
        }
    }

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.