Danny620 Posted July 17, 2017 Share Posted July 17, 2017 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? Quote Link to comment Share on other sites More sharing options...
requinix Posted July 17, 2017 Share Posted July 17, 2017 See dirname. Quote Link to comment Share on other sites More sharing options...
Danny620 Posted July 18, 2017 Author Share Posted July 18, 2017 Hi this does not seem to be working for me echo dirname($ftpObj->getCurrentDir()); Quote Link to comment Share on other sites More sharing options...
requinix Posted July 18, 2017 Share Posted July 18, 2017 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. Quote Link to comment Share on other sites More sharing options...
Danny620 Posted July 18, 2017 Author Share Posted July 18, 2017 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; } } Quote Link to comment Share on other sites More sharing options...
requinix Posted July 18, 2017 Share Posted July 18, 2017 Seems fine. Keep looking for where the problem is. Maybe the echo isn't in the right place? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.