Net_FTP::getRecursive()
Synopsis
mixed Net_FTP::getRecursive (
string $remote_path
,
string $local_path
,
bool $overwrite = false
,
int $mode = null
)
Description
This downloads a whole directory from the FTP server to the computer your script runs on.
Parameter
-
string $remote_path
- The directory you'd like to download. This could either be an absolute or relative path to a directory (path has to end with '/'). -
string $local_path
- The destination you'd like to download the directory to. You can specify this with either an absolute path or a path relative to the scripts directory. (Beware: The script directory is determined by the called script, if you use includes!) -
bool $overwrite = false
- Whether to overwrite the local files if they exist, or not. if not set the directory will not be overwritten. -
int $mode = null
- This has to be one of the constants FTP_ASCII or FTP_BINARY. if not specified, the class will try to determine the mode from the file extensions (from extensions.ini) or fall back to the standard transfer mode (attribute).
Return value
mixed
- true on success, otherwise PEAR::Error.
Throws
Several errors may be returned by getRecursive. The errornumber is unspecific (until now) and will not tell you anything about the errormessage. Possible errors are:
Error message | Description | Solution |
---|---|---|
Given remote-path '$remote_path' seems not to be a directory. | The path you specified on the FTP sever seems not to be a valid directory node. | Maybe your path does not end with '/' or the directory does not exist. |
Given local-path '$local_path' seems not to be a directory. | The path you specified on the local host seems not to be a valid directory node. | Maybe your path does not end with '/' or the directory does not exist. |
Could not create dir '$local_path'. | The given directory could not be created. | Check your permissions on the source-directory. |
Could not create dir '$local_path'. | The given directory could not be created. | Check your permissions on the source-directory. |
Note
This function can not be called statically.
Example
Using getRecursive()
<?php
var_dump($test->getRecursive('foo/', '/tmp/foo/', true));
?>