Web Hosting Talk







View Full Version : How to use ftp_chdir() to change into a FULL PATH?


mrzippy
04-12-2006, 01:57 PM
I am trying to write a simple script that will recursively copy all files from the script folder into an FTP target folder.

The problem is that I only know what is the FULL filepath to where the files should go. But the ftp_chdir() function won't work with this full path. It needs a path that is "relative" to the current ftp location after logging in.

For example:

I have the full path: /home/username/public_html/path/to/my/files/
I need the relative path to their ftp root: public_html/path/to/my/files/

Is there any way for my script to somehow figure out what is the "relative to the ftp login root" for where the new folder should be located... based on the full file path?

I have no idea beforehand what kind of server they'll be using.

ThatScriptGuy
04-12-2006, 03:57 PM
If the /path/to/my/files is constant everytime, how come you couldn't just ask them what their web root was? If it was htdocs, then you could just do /htdocs/path/to/my/files/

Kevin

mrzippy
04-12-2006, 04:00 PM
If the /path/to/my/files is constant everytime, how come you couldn't just ask them what their web root was? If it was htdocs, then you could just do /htdocs/path/to/my/files/

Kevin
I can't ask them because they won't know. That's why I'm writing the script. :)

Many servers use a different ftp root then the htdocs root, so that won't work.

:(