M
M
mozilla2019-05-31 10:22:36
PHP
mozilla, 2019-05-31 10:22:36

What code in php to organize active ftp mode?

Unfortunately, the passive mode is not suitable, you must configure the active transfer mode. Now it's set up like this:

$this->ftp = ftp_connect($this->host, $this->port, self::FTP_TIMEOUT);
        if (false === $this->ftp) {
            throw new Exception('connect fail');
        }
        if (false === ftp_login($this->ftp, $this->login, $this->pass)) {
            throw new Exception('auth fail');
        }
 if ($this->activeString) {
            preg_match('/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}):(\d{1,5})/', $this->activeString, $match);
            if (count($match) == 6) {
                $hex1 = intval($match[5] / 256);
                $hex2 = $match[5] - $hex1 * 256;
                $activeString = implode(',', [
                    $match[1],
                    $match[2],
                    $match[3],
                    $match[4],
                    $hex1,
                    $hex2
                ]);
                ftp_pasv($this->ftp, false);
                $try = ftp_raw($this->ftp, 'PORT ' . $activeString);
                return $this->ftp;
            }

Something doesn't fly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
toxa82, 2019-05-31
@toxa82

ftp_pasv - Enable or disable passive mode

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question