P
P
pingo2015-05-29 23:09:49
PHP
pingo, 2015-05-29 23:09:49

How to get the path from the root of the user having only an ftp connection to the server?

Here is such a simple question, I need to upload a file via ftp from a script to a folder on the domain.com/images/ server,
as if everything is simple

ftp_put($connect, $destination, $source, FTP_BINARY))

but in order to execute this fn, you need to know on the remote server the full path from the root to the desired folder for this particular user.
it's easy to get the full path, you can ask the server via file_get_contents(), but I can't think of something for a user who got hooked up via ftp. I also don’t want to cut the full path with a regular expression, because this is not true. as? From the root to load, too, there is no possibility and desire.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2015-05-30
@pingo

In general, no way, because it depends on the configuration of the ftp daemon: many chroot into the user's home folder, and some even virtualize the paths. Typically, scripts that update via FTP (the same phpbb) request a prefix for the FTP path to www-root from the user.
In a particular case, when ftp-access comes from the root FS, and PHP also works without cheats and other restrictions - we get the full path to the file through realpath() and give it to FTP.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question