Answer the question
In order to leave comments, you need to log in
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;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question