note 78073 added to function.ftp-pasv
| From: | vladimir at pixeltomorrow dot com | Date: | Thu, 27 Sep 2007 00:36:19 +0000 |
| Subject: | note 78073 added to function.ftp-pasv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130814@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 69.147.83.197
Probable Submitter: 89.101.121.46
----
Manual Page -- http://www.php.net/manual/en/function.ftp-pasv.php
Edit -- https://master.php.net/note/edit/78073
Del: integrated -- https://master.php.net/note/delete/78073/integrated
Del: useless -- https://master.php.net/note/delete/78073/useless
Del: bad code -- https://master.php.net/note/delete/78073/bad+code
Del: spam -- https://master.php.net/note/delete/78073/spam
Del: non-english -- https://master.php.net/note/delete/78073/non-english
Del: in docs -- https://master.php.net/note/delete/78073/in+docs
Del: other reasons-- https://master.php.net/note/delete/78073
Reject -- https://master.php.net/note/reject/78073
Search -- https://master.php.net/manage/user-notes.php