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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.