note 78073 deleted from function.ftp-pasv by nlopess
| From: | nlopess@php.net | Date: | Thu, 27 Sep 2007 22:42:28 +0000 |
| Subject: | note 78073 deleted from function.ftp-pasv by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-130869@lists.php.net to get a copy of this message | ||
Note Submitter: vladimir at pixeltomorrow dot com
----
When you're trying to activate passive mode using the ftp raw command PASV, you can process the
reply using the following regular expression:
<?php
$rule = '/^[0-9]+\s.*\(([0-9,]+),([0-9]+),([0-9]+)\).*$/im';
// $ftp_server_reply is considered the reply provided
// by the FTP server.
if (preg_match($rule, $ftp_server_reply, $m)) {
$passive_host = str_replace(',', '.', $m[1]);
$passive_port = $m[2]*256+$m[3];
}
?>
Then you can open a stream where you can send the file you want to upload, or the data you want to
operate.
This post over here explains how things work with the FTP passive mode, in a friendly way: http://tinyurl.com/2bwuqs
Cheers,
Vladimir
http://www.TopNotchCoder.com
P.S. Passive mode means opening a new connection where data is being sent when uploading files,
that's why it has to be initiated after login, considering the logical order of actions: Login
-> CWD -> upload stuff.