PEAR Manual
Prev |  | Next

# Net_FTP::putRecursive()

Net_FTP::putRecursive() -- upload a whole directory to the FTP server.

## Synopsis

    require_once 'Net/FTP.php';

``mixed Net_FTP::putrecursive` (string $local_path, string $remote_path [, bool $overwrite = false [, int $mode = null]])`

## Description

This uploads a whole directory to the FTP server from the computer your script runs on.

## Parameter

- `string $local_path` - The source directory you'd like to upload. 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!)

- `string $remote_path` - The path you'd like to upload to. This could either be an absolute or relative path to a directory.

- `bool $overwrite = false` - Whether to overwrite the remote directory if it exists, 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 putRecursive. The errornumber is unspecific (until now) and will not tell you anything about the errormessage. Possible errors are:

Table 48-1. Possible PEAR_Error values

Error message | Description | Solution
--- | --- | ---
Given local-path '$local_path' seems not to be a directory. | The local path you have specified does not seem to be a directory. | Correct the local directory path. (Does it end with '/'?)
Given remote-path '$remote_path' seems not to be a directory. | The remote path you have specified does not seem to be a directory. | Correct the local directory path. (Does it end with '/'?)

## Note

This function can not be called statically.

## Example

Example 48-1. Using putRecursive()
    <?php

        var_dump($test->putRecursive('/tmp/foo/', 'foo/', true));

    ?>

Prev | Home | Next
Net_FTP::getRecursive() | Up | Net_FTP::checkFileExtension()