= PHP_7_2_0, PHP_8 // ftp_cdup() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_chdir() - PHP_4, PHP_5, PHP_7, PHP_8 // OFFLINE | ftp_chmod() - PHP_5, PHP_7, PHP_8 // ftp_close() - PHP_4 >= PHP_4_2_0, PHP_5, PHP_7, PHP_8 // ftp_connect() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_delete() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_exec() - PHP_4 >= PHP_4_0_3, PHP_5, PHP_7, PHP_8 // ftp_fget() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_fput() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_get_option() - PHP_4 >= PHP_4_2_0, PHP_5, PHP_7, PHP_8 // ftp_get() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_login() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_mdtm() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_mkdir() - PHP_4, PHP_5, PHP_7, PHP_8 // OFFLINE | ftp_mlsd() - PHP_7 >= PHP_7_2_0, PHP_8 // ftp_nb_continue() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ftp_nb_fget() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ftp_nb_fput() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ftp_nb_get() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ftp_nb_put() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ftp_nlist() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_pasv() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_put() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_pwd() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_quit() - PHP_4, PHP_5, PHP_7, PHP_8 // OFFLINE | ftp_raw() - PHP_5, PHP_7, PHP_8 // ftp_rawlist() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_rename() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_rmdir() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_set_option() - PHP_4 >= PHP_4_2_0, PHP_5, PHP_7, PHP_8 // ftp_site() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_size() - PHP_4, PHP_5, PHP_7, PHP_8 // ftp_ssl_connect() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ftp_systype() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== USING CLASSES (0) // ============================== USING DATA_TYPES (7) // bool // OFFLINE | FTP\Connection - PHP_8 >= PHP_8_1_0 // int // string // false // resource // array // ============================== END // REQUIREMENTS // ============================== // ============================== BEGIN // PHP_OTHER_FTP // ============================== ABOUT // PHP Manual / Function Reference / Other Services / FTP // URL: https://www.php.net/manual/en/book.ftp.php // ============================== DESCRIPTION // FTP // // FTP - BEGIN // FTP // // INTRODUCTION // INSTALLING_CONFIGURING // PREDEFINED_CONSTANTS // EXAMPLES // FTP_FUNCTIONS // THE_FTP_CONNECTION_CLASS // // INTRODUCTION - BEGIN // Introduction // // The functions in this extension implement client access to files servers speaking the File Transfer Protocol (FTP) as defined in > http://www.faqs.org/rfcs/rfc959. This extension is meant for detailed access to an FTP server providing a wide range of control to the executing script. If you only wish to read from or write to a file on an FTP server, consider using the ftp:// wrapper with the filesystem functions which provide a simpler and more intuitive interface. // // LITERATURE_SOURCES // * PHP_NET (2023-09-02) // URL: https://www.php.net/manual/en/intro.ftp.php // INTRODUCTION - END // // INSTALLING_CONFIGURING - BEGIN // Installing/Configuring // // REQUIREMENTS // INSTALLATION // RUNTIME_CONFIGURATION // RESOURCE_TYPES // // REQUIREMENTS - BEGIN // Requirements // // No external libraries are needed to build this extension. // // LITERATURE_SOURCES // * PHP_NET (2023-09-02) // URL: https://www.php.net/manual/en/ftp.requirements.php // REQUIREMENTS - END // // INSTALLATION - BEGIN // Installation // // In order to use FTP functions with your PHP configuration, you should add the --enable-ftp option when installing PHP. // On Windows this extension is always built as shared extension and as such has to be enabled in php.ini. // // LITERATURE_SOURCES // * PHP_NET (2023-09-02) // URL: https://www.php.net/manual/en/ftp.installation.php // INSTALLATION - END // // RUNTIME_CONFIGURATION - BEGIN // Runtime Configuration // // This extension has no configuration directives defined in php.ini. // // LITERATURE_SOURCES // * PHP_NET (2023-09-02) // URL: https://www.php.net/manual/en/ftp.configuration.php // RUNTIME_CONFIGURATION - END // // RESOURCE_TYPES - BEGIN // Resource Types // // Prior to PHP 8.1.0, this extension used one resource type, which is the link identifier of the FTP connection, returned by ftp_connect() or ftp_ssl_connect(). // // LITERATURE_SOURCES // * PHP_NET (2023-09-02) // URL: https://www.php.net/manual/en/ftp.resources.php // RESOURCE_TYPES - END // // LITERATURE_SOURCES // * PHP_NET (2023-09-02) // URL: https://www.php.net/manual/en/ftp.setup.php // INSTALLING_CONFIGURING - END // // PREDEFINED_CONSTANTS - BEGIN // Predefined Constants // // The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. // FTP_ASCII (int) - // FTP_AUTOSEEK (int) - See ftp_set_option() for information. // FTP_AUTORESUME (int) - Automatically determine resume position and start position for GET and PUT requests (only works if FTP_AUTOSEEK is enabled) // FTP_FAILED (int) - Asynchronous transfer has failed // FTP_FINISHED (int) - Asynchronous transfer has finished // FTP_MOREDATA (int) - Asynchronous transfer is still active // FTP_TEXT (int) - Alias of FTP_ASCII. // FTP_BINARY (int) - // FTP_IMAGE (int) - Alias of FTP_BINARY. // FTP_TIMEOUT_SEC (int) - See ftp_set_option() for information. // FTP_USEPASVADDRESS (int) - See ftp_set_option() for information. // // LITERATURE_SOURCES // * PHP_NET (2023-09-02) // URL: https://www.php.net/manual/en/ftp.constants.php // PREDEFINED_CONSTANTS - END // // EXAMPLES - BEGIN // Examples // // BASIC_USAGE // // BASIC_USAGE - BEGIN // Basic usage // // [example] // Example #1 FTP example // [php] // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // check connection // if ((!$ftp) || (!$login_result)) { // echo "FTP connection has failed!"; // echo "Attempted to connect to $ftp_server for user $ftp_user_name"; // exit; // } else { // echo "Connected to $ftp_server, for user $ftp_user_name"; // } // // // upload the file // $upload = ftp_put($ftp, $destination_file, $source_file, FTP_BINARY); // // // check upload status // if (!$upload) { // echo "FTP upload has failed!"; // } else { // echo "Uploaded $source_file to $ftp_server as $destination_file"; // } // // // close the FTP connection // ftp_close($ftp); // [/php] // [/example] // // LITERATURE_SOURCES // * PHP_NET (2023-11-11) // URL: https://www.php.net/manual/en/ftp.examples-basic.php // BASIC_USAGE - END // // LITERATURE_SOURCES // * PHP_NET (2023-09-02) // URL: https://www.php.net/manual/en/ftp.examples.php // EXAMPLES - END // // FTP_FUNCTIONS - BEGIN // FTP Functions // // Table of Contents // * ftp_alloc - Allocates space for a file to be uploaded // * ftp_append - Append the contents of a file to another file on the FTP server // * ftp_cdup - Changes to the parent directory // * ftp_chdir - Changes the current directory on a FTP server // * ftp_chmod - Set permissions on a file via FTP // * ftp_close - Closes an FTP connection // * ftp_connect - Opens an FTP connection // * ftp_delete - Deletes a file on the FTP server // * ftp_exec - Requests execution of a command on the FTP server // * ftp_fget - Downloads a file from the FTP server and saves to an open file // * ftp_fput - Uploads from an open file to the FTP server // * ftp_get_option - Retrieves various runtime behaviours of the current FTP connection // * ftp_get - Downloads a file from the FTP server // * ftp_login - Logs in to an FTP connection // * ftp_mdtm - Returns the last modified time of the given file // * ftp_mkdir - Creates a directory // * ftp_mlsd - Returns a list of files in the given directory // * ftp_nb_continue - Continues retrieving/sending a file (non-blocking) // * ftp_nb_fget - Retrieves a file from the FTP server and writes it to an open file (non-blocking) // * ftp_nb_fput - Stores a file from an open file to the FTP server (non-blocking) // * ftp_nb_get - Retrieves a file from the FTP server and writes it to a local file (non-blocking) // * ftp_nb_put - Stores a file on the FTP server (non-blocking) // * ftp_nlist - Returns a list of files in the given directory // * ftp_pasv - Turns passive mode on or off // * ftp_put - Uploads a file to the FTP server // * ftp_pwd - Returns the current directory name // * ftp_quit - Alias of ftp_close // * ftp_raw - Sends an arbitrary command to an FTP server // * ftp_rawlist - Returns a detailed list of files in the given directory // * ftp_rename - Renames a file or a directory on the FTP server // * ftp_rmdir - Removes a directory // * ftp_set_option - Set miscellaneous runtime FTP options // * ftp_site - Sends a SITE command to the server // * ftp_size - Returns the size of the given file // * ftp_ssl_connect - Opens a Secure SSL-FTP connection // * ftp_systype - Returns the system type identifier of the remote FTP server // // LITERATURE_SOURCES // * PHP_NET (2023-09-02) // URL: https://www.php.net/manual/en/ref.ftp.php // FTP_FUNCTIONS - END // // THE_FTP_CONNECTION_CLASS - BEGIN // The FTP\Connection class // // PHP_8 >= PHP_8_1_0 // // Introduction // A fully opaque class which replaces a ftp resource as of PHP 8.1.0. // // Class synopsis // [code] // final class FTP\Connection { // } // [/code] // // LITERATURE_SOURCES // * PHP_NET (2023-11-11) // URL: https://www.php.net/manual/en/class.ftp-connection.php // THE_FTP_CONNECTION_CLASS - END // // LITERATURE_SOURCES // * PHP_NET (2023-09-02) // URL: https://www.php.net/manual/en/book.ftp.php // FTP - END // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_ALLOC // ============================== OFFLINE // ============================== ABOUT // Allocates space for a file to be uploaded. // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_alloc() - PHP_5, PHP_7, PHP_8 // ============================== CODE /* function php_other_ftp_ftp_alloc($ftp, $size, & $response) { $return_ftp_alloc = false; // ========== FTP_ALLOC - BEGIN // ===== ABOUT // Allocates space for a file to be uploaded // ===== DESCRIPTION // Sends an ALLO command to the remote FTP server to allocate space for a file to be uploaded. // Note: Many FTP servers do not support this command. These servers may return a failure code (false) indicating the command is not supported or a success code (true) to indicate that pre-allocation is not necessary and the client should continue as though the operation were successful. Because of this, it may be best to reserve this function for servers which explicitly require preallocation. // ===== SUPPORTED // PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_alloc(FTP\Connection $ftp, int $size, string &$response = null): bool // ===== CODE $return_ftp_alloc = ftp_alloc( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $size, // int size - The number of bytes to allocate. $response // string& response - A textual representation of the servers response will be returned by reference in response if a variable is provided. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_alloc() example // [php] // // $file = "/home/user/myfile"; // // // connect to the server // $ftp = ftp_connect('ftp.example.com'); // $login_result = ftp_login($ftp, 'anonymous', 'user@example.com'); // // if (ftp_alloc($ftp, filesize($file), $result)) { // echo "Space successfully allocated on server. Sending $file.\n"; // ftp_put($ftp, '/incoming/myfile', $file, FTP_BINARY); // } else { // echo "Unable to allocate space on server. Server said: $result\n"; // } // // ftp_close($ftp); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-08) // URL: https://www.php.net/manual/en/function.ftp-alloc.php // ========== FTP_ALLOC - END // SYNTAX: // bool ftp_alloc(FTP\Connection $ftp, int $size, string& $response) return $return_ftp_alloc; // bool } */ // ============================== END // PHP_OTHER_FTP_FTP_ALLOC // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_APPEND // ============================== OFFLINE // ============================== ABOUT // Append the contents of a file to another file on the FTP server. // ============================== SUPPORT // PHP_7 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_append() - PHP_7 >= PHP_7_2_0, PHP_8 // ============================== USING CONSTANTS (1) // FTP_BINARY - ftp_append() // ============================== CODE /* function php_other_ftp_ftp_append($ftp, $remote_filename, $local_filename, $mode = FTP_BINARY) { $return_ftp_append = false; // ========== FTP_APPEND - BEGIN // ===== ABOUT // Append the contents of a file to another file on the FTP server // ===== DESCRIPTION // Warning: This function is currently not documented; only its argument list is available. // ===== SUPPORTED // PHP_7 >= PHP_7_2_0, PHP_8 // ===== SYNTAX // ftp_append( // FTP\Connection $ftp, // string $remote_filename, // string $local_filename, // int $mode = FTP_BINARY // ): bool // ===== CODE $return_ftp_append = ftp_append( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $remote_filename, // string remote_filename $local_filename, // string local_filename $mode // int mode ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-22) // URL: https://www.php.net/manual/en/function.ftp-append.php // ========== FTP_APPEND - END // SYNTAX: // bool ftp_append(FTP\Connection $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY) return $return_ftp_append; // bool } */ // ============================== END // PHP_OTHER_FTP_FTP_APPEND // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_CDUP // ============================== PUBLIC // ============================== ABOUT // Changes to the parent directory. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_cdup() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_cdup($ftp) { $return_ftp_cdup = false; // ========== FTP_CDUP - BEGIN // ===== ABOUT // Changes to the parent directory // ===== DESCRIPTION // Changes to the parent directory. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_cdup(FTP\Connection $ftp): bool // ===== CODE $return_ftp_cdup = ftp_cdup( $ftp // FTP\Connection ftp - An FTP\Connection instance. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_cdup() example // [php] // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // change the current directory to html // ftp_chdir($ftp, 'html'); // // echo ftp_pwd($ftp); // /html // // // return to the parent directory // if (ftp_cdup($ftp)) { // echo "cdup successful\n"; // } else { // echo "cdup not successful\n"; // } // // echo ftp_pwd($ftp); // / // // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-cdup.php // ========== FTP_CDUP - END // SYNTAX: // bool ftp_cdup(FTP\Connection $ftp) return $return_ftp_cdup; // bool } // ============================== END // PHP_OTHER_FTP_FTP_CDUP // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_CHDIR // ============================== PUBLIC // ============================== ABOUT // Changes the current directory on a FTP server. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_chdir() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_chdir($ftp, $directory) { $return_ftp_chdir = false; // ========== FTP_CHDIR - BEGIN // ===== ABOUT // Changes the current directory on a FTP server // ===== DESCRIPTION // Changes the current directory to the specified one. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_chdir(FTP\Connection $ftp, string $directory): bool // ===== CODE $return_ftp_chdir = ftp_chdir( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $directory // string directory - The target directory. ); // Return Values // Returns true on success or false on failure. If changing directory fails, PHP will also throw a warning. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_chdir() example // [php] // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // check connection // if ((!$ftp) || (!$login_result)) { // die("FTP connection has failed !"); // } // // echo "Current directory: " . ftp_pwd($ftp) . "\n"; // // // try to change the directory to somedir // if (ftp_chdir($ftp, "somedir")) { // echo "Current directory is now: " . ftp_pwd($ftp) . "\n"; // } else { // echo "Couldn't change directory\n"; // } // // // close the connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-chdir.php // ========== FTP_CHDIR - END // SYNTAX: // bool ftp_chdir(FTP\Connection $ftp, string $directory) return $return_ftp_chdir; // bool } // ============================== END // PHP_OTHER_FTP_FTP_CHDIR // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_CHMOD // ============================== OFFLINE // ============================== ABOUT // Set permissions on a file via FTP. // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_chmod() - PHP_5, PHP_7, PHP_8 // ============================== CODE /* function php_other_ftp_ftp_chmod($ftp, $permissions, $filename) { $return_ftp_chmod = false; // ========== FTP_CHMOD - BEGIN // ===== ABOUT // Set permissions on a file via FTP // ===== DESCRIPTION // Sets the permissions on the specified remote file to permissions. // ===== SUPPORTED // PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_chmod(FTP\Connection $ftp, int $permissions, string $filename): int|false // ===== CODE $return_ftp_chmod = ftp_chmod( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $permissions, // int permissions - The new permissions, given as an octal value. $filename // string filename - The remote file. ); // Return Values // Returns the new file permissions on success or false on error. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_chmod() example // [php] // $file = 'public_html/index.php'; // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // try to chmod $file to 644 // if (ftp_chmod($ftp, 0644, $file) !== false) { // echo "$file chmoded successfully to 644\n"; // } else { // echo "could not chmod $file\n"; // } // // // close the connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-08) // URL: https://www.php.net/manual/en/function.ftp-chmod.php // ========== FTP_CHMOD - END // SYNTAX: // int|false ftp_chmod(FTP\Connection $ftp, int $permissions, string $filename) return $return_ftp_chmod; // int|false } */ // ============================== END // PHP_OTHER_FTP_FTP_CHMOD // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_CLOSE // ============================== PUBLIC // ============================== ABOUT // Closes an FTP connection. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_close() - PHP_4 >= PHP_4_2_0, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_close($ftp) { $return_ftp_close = false; // ========== FTP_CLOSE - BEGIN // ===== ABOUT // Closes an FTP connection // ===== DESCRIPTION // ftp_close() closes the given link identifier and releases the resource. // Note: After calling this function, you can no longer use the FTP connection and must create a new one with ftp_connect(). // ===== SUPPORTED // PHP_4 >= PHP_4_2_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_close(FTP\Connection $ftp): bool // ===== CODE $return_ftp_close = ftp_close( $ftp // FTP\Connection ftp - An FTP\Connection instance. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_close() example // [php] // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // print the current directory // echo ftp_pwd($ftp); // // // close this connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-close.php // ========== FTP_CLOSE - END // SYNTAX: // bool ftp_close(FTP\Connection $ftp) return $return_ftp_close; // bool } // ============================== END // PHP_OTHER_FTP_FTP_CLOSE // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_CONNECT // ============================== PUBLIC // ============================== ABOUT // Opens an FTP connection. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_connect() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_connect($hostname, $port = 21, $timeout = 90) { $return_ftp_connect = false; // ========== FTP_CONNECT - BEGIN // ===== ABOUT // Opens an FTP connection // ===== DESCRIPTION // ftp_connect() opens an FTP connection to the specified hostname. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_connect(string $hostname, int $port = 21, int $timeout = 90): FTP\Connection|false // ===== CODE $return_ftp_connect = ftp_connect( $hostname, // string hostname - The FTP server address. This parameter shouldn't have any trailing slashes and shouldn't be prefixed with ftp://. $port, // int port - This parameter specifies an alternate port to connect to. If it is omitted or set to zero, then the default FTP port, 21, will be used. $timeout // int timeout - This parameter specifies the timeout in seconds for all subsequent network operations. If omitted, the default value is 90 seconds. The timeout can be changed and queried at any time with ftp_set_option() and ftp_get_option(). ); // Return Values // Returns an FTP\Connection instance on success, or false on failure. // // Changelog // Version - Description // 8.1.0 - Returns an FTP\Connection instance now; previously, a resource was returned. // // [examples] // Examples // [example] // Example #1 ftp_connect() example // [php] // // $ftp_server = "ftp.example.com"; // // // set up a connection or die // $ftp = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-connect.php // ========== FTP_CONNECT - END // SYNTAX: // FTP\Connection|false ftp_connect(string $hostname, int $port = 21, int $timeout = 90) return $return_ftp_connect; // FTP\Connection|false } // ============================== END // PHP_OTHER_FTP_FTP_CONNECT // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_DELETE // ============================== PUBLIC // ============================== ABOUT // Deletes a file on the FTP server. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_delete() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_delete($ftp, $filename) { $return_ftp_delete = false; // ========== FTP_DELETE - BEGIN // ===== ABOUT // Deletes a file on the FTP server // ===== DESCRIPTION // ftp_delete() deletes the file specified by filename from the FTP server. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_delete(FTP\Connection $ftp, string $filename): bool // ===== CODE $return_ftp_delete = ftp_delete( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $filename // string filename - The file to delete. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_delete() example // [php] // $file = 'public_html/old.txt'; // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // try to delete $file // if (ftp_delete($ftp, $file)) { // echo "$file deleted successful\n"; // } else { // echo "could not delete $file\n"; // } // // // close the connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-delete.php // ========== FTP_DELETE - END // SYNTAX: // bool ftp_delete(FTP\Connection $ftp, string $filename) return $return_ftp_delete; // bool } // ============================== END // PHP_OTHER_FTP_FTP_DELETE // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_EXEC // ============================== PUBLIC // ============================== ABOUT // Requests execution of a command on the FTP server. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_exec() - PHP_4 >= PHP_4_0_3, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_exec($ftp, $command) { $return_ftp_exec = false; // ========== FTP_EXEC - BEGIN // ===== ABOUT // Requests execution of a command on the FTP server // ===== DESCRIPTION // Sends a SITE EXEC command request to the FTP server. // ===== SUPPORTED // PHP_4 >= PHP_4_0_3, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_exec(FTP\Connection $ftp, string $command): bool // ===== CODE $return_ftp_exec = ftp_exec( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $command // string command - The command to execute. ); // Return Values // Returns true if the command was successful (server sent response code: 200); otherwise returns false. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_exec() example // [php] // // // variable initialization // $command = 'ls -al >files.txt'; // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // execute command // if (ftp_exec($ftp, $command)) { // echo "$command executed successfully\n"; // } else { // echo "could not execute $command\n"; // } // // // close the connection // ftp_close($ftp); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-exec.php // ========== FTP_EXEC - END // SYNTAX: // bool ftp_exec(FTP\Connection $ftp, string $command) return $return_ftp_exec; // bool } // ============================== END // PHP_OTHER_FTP_FTP_EXEC // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_FGET // ============================== PUBLIC // ============================== ABOUT // Downloads a file from the FTP server and saves to an open file. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_fget() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== USING CONSTANTS (1) // FTP_BINARY - ftp_fget() // ============================== CODE function php_other_ftp_ftp_fget($ftp, $stream, $remote_filename, $mode = FTP_BINARY, $offset = 0) { $return_ftp_fget = false; // ========== FTP_FGET - BEGIN // ===== ABOUT // Downloads a file from the FTP server and saves to an open file // ===== DESCRIPTION // ftp_fget() retrieves remote_filename from the FTP server, and writes it to the given file pointer. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_fget( // FTP\Connection $ftp, // resource $stream, // string $remote_filename, // int $mode = FTP_BINARY, // int $offset = 0 // ): bool // ===== CODE $return_ftp_fget = ftp_fget( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $stream, // resource stream - An open file pointer in which we store the data. $remote_filename, // string remote_filename - The remote file path. $mode, // int mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. $offset // int offset - The position in the remote file to start downloading from. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // 7.3.0 - The mode parameter is now optional. Formerly it has been mandatory. // // [examples] // Examples // [example] // Example #1 ftp_fget() example // [php] // // // path to remote file // $remote_file = 'somefile.txt'; // $local_file = 'localfile.txt'; // // // open some file to write to // $handle = fopen($local_file, 'w'); // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // try to download $remote_file and save it to $handle // if (ftp_fget($ftp, $handle, $remote_file, FTP_ASCII, 0)) { // echo "successfully written to $local_file\n"; // } else { // echo "There was a problem while downloading $remote_file to $local_file\n"; // } // // // close the connection and the file handler // ftp_close($ftp); // fclose($handle); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-fget.php // ========== FTP_FGET - END // SYNTAX: // bool ftp_fget(FTP\Connection $ftp, resource $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0) return $return_ftp_fget; // bool } // ============================== END // PHP_OTHER_FTP_FTP_FGET // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_FPUT // ============================== PUBLIC // ============================== ABOUT // Uploads from an open file to the FTP server. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_fput() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== USING CONSTANTS (1) // FTP_BINARY - ftp_fput() // ============================== CODE function php_other_ftp_ftp_fput($ftp, $remote_filename, $stream, $mode = FTP_BINARY, $offset = 0) { $return_ftp_fput = false; // ========== FTP_FPUT - BEGIN // ===== ABOUT // Uploads from an open file to the FTP server // ===== DESCRIPTION // ftp_fput() uploads the data from a file pointer to a remote file on the FTP server. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_fput( // FTP\Connection $ftp, // string $remote_filename, // resource $stream, // int $mode = FTP_BINARY, // int $offset = 0 // ): bool // ===== CODE $return_ftp_fput = ftp_fput( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $remote_filename, // string remote_filename - The remote file path. $stream, // resource stream - An open file pointer on the local file. Reading stops at end of file. $mode, // int mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. $offset // int offset - The position in the remote file to start uploading to. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // 7.3.0 - The mode parameter is now optional. Formerly it has been mandatory. // // [examples] // Examples // [example] // Example #1 ftp_fput() example // [php] // // // open some file for reading // $file = 'somefile.txt'; // $fp = fopen($file, 'r'); // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // try to upload $file // if (ftp_fput($ftp, $file, $fp, FTP_ASCII)) { // echo "Successfully uploaded $file\n"; // } else { // echo "There was a problem while uploading $file\n"; // } // // // close the connection and the file handler // ftp_close($ftp); // fclose($fp); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-fput.php // ========== FTP_FPUT - END // SYNTAX: // bool ftp_fput(FTP\Connection $ftp, string $remote_filename, resource $stream, int $mode = FTP_BINARY, int $offset = 0) return $return_ftp_fput; // bool } // ============================== END // PHP_OTHER_FTP_FTP_FPUT // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_GET_OPTION // ============================== PUBLIC // ============================== ABOUT // Retrieves various runtime behaviours of the current FTP connection. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_get_option() - PHP_4 >= PHP_4_2_0, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_get_option($ftp, $option) { $return_ftp_get_option = false; // ========== FTP_GET_OPTION - BEGIN // ===== ABOUT // Retrieves various runtime behaviours of the current FTP connection // ===== DESCRIPTION // This function returns the value for the requested option from the specified FTP connection. // ===== SUPPORTED // PHP_4 >= PHP_4_2_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_get_option(FTP\Connection $ftp, int $option): int|bool // ===== CODE $return_ftp_get_option = ftp_get_option( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $option // int option - Currently, the following options are supported: // Supported runtime FTP options // FTP_TIMEOUT_SEC - Returns the current timeout used for network related operations. // FTP_AUTOSEEK - Returns true if this option is on, false otherwise. ); // Return Values // Returns the value on success or false if the given option is not supported. In the latter case, a warning message is also thrown. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_get_option() example // [php] // // Get the timeout of the given FTP connection // $timeout = ftp_get_option($ftp, FTP_TIMEOUT_SEC); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-get-option.php // ========== FTP_GET_OPTION - END // SYNTAX: // int|bool ftp_get_option(FTP\Connection $ftp, int $option) return $return_ftp_get_option; // int|bool } // ============================== END // PHP_OTHER_FTP_FTP_GET_OPTION // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_GET // ============================== PUBLIC // ============================== ABOUT // Downloads a file from the FTP server. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_get() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== USING CONSTANTS (1) // FTP_BINARY - ftp_get() // ============================== CODE function php_other_ftp_ftp_get($ftp, $local_filename, $remote_filename, $mode = FTP_BINARY, $offset = 0) { $return_ftp_get = false; // ========== FTP_GET - BEGIN // ===== ABOUT // Downloads a file from the FTP server // ===== DESCRIPTION // ftp_get() retrieves a remote file from the FTP server, and saves it into a local file. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_get( // FTP\Connection $ftp, // string $local_filename, // string $remote_filename, // int $mode = FTP_BINARY, // int $offset = 0 // ): bool // ===== CODE $return_ftp_get = ftp_get( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $local_filename, // string local_filename - The local file path (will be overwritten if the file already exists). $remote_filename, // string remote_filename - The remote file path. $mode, // int mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. $offset // int offset - The position in the remote file to start downloading from. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // 7.3.0 - The mode parameter is now optional. Formerly it has been mandatory. // // [examples] // Examples // [example] // Example #1 ftp_get() example // [php] // // // define some variables // $local_file = 'local.zip'; // $server_file = 'server.zip'; // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // try to download $server_file and save to $local_file // if (ftp_get($ftp, $local_file, $server_file, FTP_BINARY)) { // echo "Successfully written to $local_file\n"; // } else { // echo "There was a problem\n"; // } // // // close the connection // ftp_close($ftp); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-get.php // ========== FTP_GET - END // SYNTAX: // bool ftp_get(FTP\Connection $ftp, string $local_filename, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0) return $return_ftp_get; // bool } // ============================== END // PHP_OTHER_FTP_FTP_GET // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_LOGIN // ============================== PUBLIC // ============================== ABOUT // Logs in to an FTP connection. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_login() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_login($ftp, $username, $password) { $return_ftp_login = false; // ========== FTP_LOGIN - BEGIN // ===== ABOUT // Logs in to an FTP connection // ===== DESCRIPTION // Logs in to the given FTP connection. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_login(FTP\Connection $ftp, string $username, string $password): bool // ===== CODE $return_ftp_login = ftp_login( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $username, // string username - The username (USER). $password // string password - The password (PASS). ); // Return Values // Returns true on success or false on failure. If login fails, PHP will also throw a warning. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_login() example // [php] // // $ftp_server = "ftp.example.com"; // $ftp_user = "foo"; // $ftp_pass = "bar"; // // // set up a connection or die // $ftp = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); // // // try to login // if (@ftp_login($ftp, $ftp_user, $ftp_pass)) { // echo "Connected as $ftp_user@$ftp_server\n"; // } else { // echo "Couldn't connect as $ftp_user\n"; // } // // // close the connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-login.php // ========== FTP_LOGIN - END // SYNTAX: // bool ftp_login(FTP\Connection $ftp, string $username, string $password) return $return_ftp_login; // bool } // ============================== END // PHP_OTHER_FTP_FTP_LOGIN // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_MDTM // ============================== PUBLIC // ============================== ABOUT // Returns the last modified time of the given file. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_mdtm() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_mdtm($ftp, $filename) { $return_ftp_mdtm = 0; // ========== FTP_MDTM - BEGIN // ===== ABOUT // Returns the last modified time of the given file // ===== DESCRIPTION // ftp_mdtm() gets the last modified time for a remote file. // Note: Not all servers support this feature! // Note: ftp_mdtm() does not work with directories. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_mdtm(FTP\Connection $ftp, string $filename): int // ===== CODE $return_ftp_mdtm = ftp_mdtm( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $filename // string filename - The file from which to extract the last modification time. ); // Return Values // Returns the last modified time as a local Unix timestamp on success, or -1 on error. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_mdtm() example // [php] // // $file = 'somefile.txt'; // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // get the last modified time // $buff = ftp_mdtm($ftp, $file); // // if ($buff != -1) { // // somefile.txt was last modified on: March 26 2003 14:16:41. // echo "$file was last modified on : " . date("F d Y H:i:s.", $buff); // } else { // echo "Couldn't get mdtime"; // } // // // close the connection // ftp_close($ftp); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-mdtm.php // ========== FTP_MDTM - END // SYNTAX: // int ftp_mdtm(FTP\Connection $ftp, string $filename) return $return_ftp_mdtm; // int } // ============================== END // PHP_OTHER_FTP_FTP_MDTM // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_MKDIR // ============================== PUBLIC // ============================== ABOUT // Creates a directory. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_mkdir() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_mkdir($ftp, $directory) { $return_ftp_mkdir = false; // ========== FTP_MKDIR - BEGIN // ===== ABOUT // Creates a directory // ===== DESCRIPTION // Creates the specified directory on the FTP server. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_mkdir(FTP\Connection $ftp, string $directory): string|false // ===== CODE $return_ftp_mkdir = ftp_mkdir( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $directory // string directory - The name of the directory that will be created. ); // Return Values // Returns the newly created directory name on success or false on error. // // Errors/Exceptions // Emits an E_WARNING level error if the directory already exists or the relevant permissions prevent creating the directory. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_mkdir() example // [php] // // $dir = 'www'; // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // try to create the directory $dir // if (ftp_mkdir($ftp, $dir)) { // echo "successfully created $dir\n"; // } else { // echo "There was a problem while creating $dir\n"; // } // // // close the connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-mkdir.php // ========== FTP_MKDIR - END // SYNTAX: // string|false ftp_mkdir(FTP\Connection $ftp, string $directory) return $return_ftp_mkdir; // string|false } // ============================== END // PHP_OTHER_FTP_FTP_MKDIR // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_MLSD // ============================== OFFLINE // ============================== ABOUT // Returns a list of files in the given directory. // ============================== SUPPORT // PHP_7 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_mlsd() - PHP_7 >= PHP_7_2_0, PHP_8 // ============================== CODE /* function php_other_ftp_ftp_mlsd($ftp, $directory) { $return_ftp_mlsd = false; // ========== FTP_MLSD - BEGIN // ===== ABOUT // Returns a list of files in the given directory // ===== DESCRIPTION // ===== SUPPORTED // PHP_7 >= PHP_7_2_0, PHP_8 // ===== SYNTAX // ftp_mlsd(FTP\Connection $ftp, string $directory): array|false // ===== CODE $return_ftp_mlsd = ftp_mlsd( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $directory // string directory - The directory to be listed. ); // Return Values // Returns an array of arrays with file infos from the specified directory on success or false on error. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_mlsd() example // [php] // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // get contents of the current directory // $contents = ftp_mlsd($ftp, "."); // // // output $contents // var_dump($contents); // // [/php] // The above example will output something similar to: // [result] // array(5) { // [0]=> // array(8) { // ["name"]=> // string(1) "." // ["modify"]=> // string(14) "20171212154511" // ["perm"]=> // string(7) "flcdmpe" // ["type"]=> // string(4) "cdir" // ["unique"]=> // string(11) "811U5740002" // ["UNIX.group"]=> // string(2) "33" // ["UNIX.mode"]=> // string(4) "0755" // ["UNIX.owner"]=> // string(2) "33" // } // [1]=> // array(8) { // ["name"]=> // string(2) ".." // ["modify"]=> // string(14) "20171212154511" // ["perm"]=> // string(7) "flcdmpe" // ["type"]=> // string(4) "pdir" // ["unique"]=> // string(11) "811U5740002" // ["UNIX.group"]=> // string(2) "33" // ["UNIX.mode"]=> // string(4) "0755" // ["UNIX.owner"]=> // string(2) "33" // } // [2]=> // array(8) { // ["name"]=> // string(11) "public_html" // ["modify"]=> // string(14) "20171211171525" // ["perm"]=> // string(7) "flcdmpe" // ["type"]=> // string(3) "dir" // ["unique"]=> // string(11) "811U5740525" // ["UNIX.group"]=> // string(2) "33" // ["UNIX.mode"]=> // string(4) "0755" // ["UNIX.owner"]=> // string(2) "33" // } // [3]=> // array(8) { // ["name"]=> // string(10) "public_ftp" // ["modify"]=> // string(14) "20171211174536" // ["perm"]=> // string(7) "flcdmpe" // ["type"]=> // string(3) "dir" // ["unique"]=> // string(11) "811U57405EE" // ["UNIX.group"]=> // string(2) "33" // ["UNIX.mode"]=> // string(4) "0755" // ["UNIX.owner"]=> // string(2) "33" // } // [4]=> // array(8) { // ["name"]=> // string(3) "www" // ["modify"]=> // string(14) "www" // ["perm"]=> // string(7) "flcdmpe" // ["type"]=> // string(3) "dir" // ["unique"]=> // string(11) "811U5740780" // ["UNIX.group"]=> // string(2) "33" // ["UNIX.mode"]=> // string(4) "0755" // ["UNIX.owner"]=> // string(2) "33" // } // } // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-mlsd.php // ========== FTP_MLSD - END // SYNTAX: // array|false ftp_mlsd(FTP\Connection $ftp, string $directory) return $return_ftp_mlsd; // array|false } */ // ============================== END // PHP_OTHER_FTP_FTP_MLSD // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_NB_CONTINUE // ============================== PUBLIC // ============================== ABOUT // Continues retrieving/sending a file (non-blocking). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_nb_continue() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_nb_continue($ftp) { $return_ftp_nb_continue = 0; // ========== FTP_NB_CONTINUE - BEGIN // ===== ABOUT // Continues retrieving/sending a file (non-blocking) // ===== DESCRIPTION // Continues retrieving/sending a file non-blocking. // ===== SUPPORTED // PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_nb_continue(FTP\Connection $ftp): int // ===== CODE $return_ftp_nb_continue = ftp_nb_continue( $ftp // FTP\Connection ftp - An FTP\Connection instance. ); // Return Values // Returns FTP_FAILED or FTP_FINISHED or FTP_MOREDATA. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_nb_continue() example // [php] // // // Initiate the download // $ret = ftp_nb_get($ftp, "test", "README", FTP_BINARY); // while ($ret == FTP_MOREDATA) { // // // Continue downloading... // $ret = ftp_nb_continue($ftp); // } // if ($ret != FTP_FINISHED) { // echo "There was an error downloading the file..."; // exit(1); // } // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-nb-continue.php // ========== FTP_NB_CONTINUE - END // SYNTAX: // int ftp_nb_continue(FTP\Connection $ftp) return $return_ftp_nb_continue; // int } // ============================== END // PHP_OTHER_FTP_FTP_NB_CONTINUE // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_NB_FGET // ============================== PUBLIC // ============================== ABOUT // Retrieves a file from the FTP server and writes it to an open file (non-blocking). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_nb_fget() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ============================== USING CONSTANTS (1) // FTP_BINARY - ftp_nb_fget() // ============================== CODE function php_other_ftp_ftp_nb_fget($ftp, $stream, $remote_filename, $mode = FTP_BINARY, $offset = 0) { $return_ftp_nb_fget = 0; // ========== FTP_NB_FGET - BEGIN // ===== ABOUT // Retrieves a file from the FTP server and writes it to an open file (non-blocking) // ===== DESCRIPTION // ftp_nb_fget() retrieves a remote file from the FTP server. // The difference between this function and ftp_fget() is that this function retrieves the file asynchronously, so your program can perform other operations while the file is being downloaded. // ===== SUPPORTED // PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_nb_fget( // FTP\Connection $ftp, // resource $stream, // string $remote_filename, // int $mode = FTP_BINARY, // int $offset = 0 // ): int // ===== CODE $return_ftp_nb_fget = ftp_nb_fget( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $stream, // resource stream - An open file pointer in which we store the data. $remote_filename, // string remote_filename - The remote file path. $mode, // int mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. $offset // int offset - The position in the remote file to start downloading from. ); // Return Values // Returns FTP_FAILED or FTP_FINISHED or FTP_MOREDATA. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // 7.3.0 - The mode parameter is now optional. Formerly it has been mandatory. // // [examples] // Examples // [example] // Example #1 ftp_nb_fget() example // [php] // // // open some file for reading // $file = 'index.php'; // $fp = fopen($file, 'w'); // // $ftp = ftp_connect($ftp_server); // // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // Initiate the download // $ret = ftp_nb_fget($ftp, $fp, $file, FTP_BINARY); // while ($ret == FTP_MOREDATA) { // // // Do whatever you want // echo "."; // // // Continue downloading... // $ret = ftp_nb_continue($ftp); // } // if ($ret != FTP_FINISHED) { // echo "There was an error downloading the file..."; // exit(1); // } // // // close filepointer // fclose($fp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-nb-fget.php // ========== FTP_NB_FGET - END // SYNTAX: // int ftp_nb_fget(FTP\Connection $ftp, resource $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0) return $return_ftp_nb_fget; // int } // ============================== END // PHP_OTHER_FTP_FTP_NB_FGET // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_NB_FPUT // ============================== PUBLIC // ============================== ABOUT // Stores a file from an open file to the FTP server (non-blocking). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_nb_fput() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ============================== USING CONSTANTS (1) // FTP_BINARY - ftp_nb_fput() // ============================== CODE function php_other_ftp_ftp_nb_fput($ftp, $remote_filename, $stream, $mode = FTP_BINARY, $offset = 0) { $return_ftp_nb_fput = 0; // ========== FTP_NB_FPUT - BEGIN // ===== ABOUT // Stores a file from an open file to the FTP server (non-blocking) // ===== DESCRIPTION // ftp_nb_fput() uploads the data from a file pointer to a remote file on the FTP server. // The difference between this function and the ftp_fput() is that this function uploads the file asynchronously, so your program can perform other operations while the file is being uploaded. // ===== SUPPORTED // PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_nb_fput( // FTP\Connection $ftp, // string $remote_filename, // resource $stream, // int $mode = FTP_BINARY, // int $offset = 0 // ): int // ===== CODE $return_ftp_nb_fput = ftp_nb_fput( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $remote_filename, // string remote_filename - The remote file path. $stream, // resource stream - An open file pointer on the local file. Reading stops at end of file. $mode, // int mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. $offset // int offset - The position in the remote file to start uploading to. ); // Return Values // Returns FTP_FAILED or FTP_FINISHED or FTP_MOREDATA. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // 7.3.0 - The mode parameter is now optional. Formerly it has been mandatory. // // [examples] // Examples // [example] // Example #1 ftp_nb_fput() example // [php] // // $file = 'index.php'; // // $fp = fopen($file, 'r'); // // $ftp = ftp_connect($ftp_server); // // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // Initiate the upload // $ret = ftp_nb_fput($ftp, $file, $fp, FTP_BINARY); // while ($ret == FTP_MOREDATA) { // // // Do whatever you want // echo "."; // // // Continue upload... // $ret = ftp_nb_continue($ftp); // } // if ($ret != FTP_FINISHED) { // echo "There was an error uploading the file..."; // exit(1); // } // // fclose($fp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-03-26) // URL: https://www.php.net/manual/en/function.ftp-nb-fput.php // ========== FTP_NB_FPUT - END // SYNTAX: // int ftp_nb_fput(FTP\Connection $ftp, string $remote_filename, resource $stream, int $mode = FTP_BINARY, int $offset = 0) return $return_ftp_nb_fput; // int } // ============================== END // PHP_OTHER_FTP_FTP_NB_FPUT // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_NB_GET // ============================== PUBLIC // ============================== ABOUT // Retrieves a file from the FTP server and writes it to a local file (non-blocking). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_nb_get() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ============================== USING CONSTANTS (1) // FTP_BINARY - ftp_nb_get() // ============================== CODE function php_other_ftp_ftp_nb_get($ftp, $local_filename, $remote_filename, $mode = FTP_BINARY, $offset = 0) { $return_ftp_nb_get = false; // ========== FTP_NB_GET - BEGIN // ===== ABOUT // Retrieves a file from the FTP server and writes it to a local file (non-blocking) // ===== DESCRIPTION // ftp_nb_get() retrieves a remote file from the FTP server, and saves it into a local file. // The difference between this function and ftp_get() is that this function retrieves the file asynchronously, so your program can perform other operations while the file is being downloaded. // ===== SUPPORTED // PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_nb_get( // FTP\Connection $ftp, // string $local_filename, // string $remote_filename, // int $mode = FTP_BINARY, // int $offset = 0 // ): int|false // ===== CODE $return_ftp_nb_get = ftp_nb_get( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $local_filename, // string local_filename - The local file path (will be overwritten if the file already exists). $remote_filename, // string remote_filename - The remote file path. $mode, // int mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. $offset // int offset - The position in the remote file to start downloading from. ); // Return Values // Returns FTP_FAILED or FTP_FINISHED or FTP_MOREDATA, or false on failure to open the local file. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // 7.3.0 - The mode parameter is now optional. Formerly it has been mandatory. // // [examples] // Examples // [example] // Example #1 ftp_nb_get() example // [php] // // // Initiate the download // $ret = ftp_nb_get($ftp, "test", "README", FTP_BINARY); // while ($ret == FTP_MOREDATA) { // // // Do whatever you want // echo "."; // // // Continue downloading... // $ret = ftp_nb_continue($ftp); // } // if ($ret != FTP_FINISHED) { // echo "There was an error downloading the file..."; // exit(1); // } // [/php] // [/example] // [example] // Example #2 Resuming a download with ftp_nb_get() // [php] // // // Initiate // $ret = ftp_nb_get($ftp, "test", "README", FTP_BINARY, // filesize("test")); // // OR: $ret = ftp_nb_get($ftp, "test", "README", // // FTP_BINARY, FTP_AUTORESUME); // while ($ret == FTP_MOREDATA) { // // // Do whatever you want // echo "."; // // // Continue downloading... // $ret = ftp_nb_continue($ftp); // } // if ($ret != FTP_FINISHED) { // echo "There was an error downloading the file..."; // exit(1); // } // [/php] // [/example] // [example] // Example #3 Resuming a download at position 100 to a new file with ftp_nb_get() // [php] // // // Disable Autoseek // ftp_set_option($ftp, FTP_AUTOSEEK, false); // // // Initiate // $ret = ftp_nb_get($ftp, "newfile", "README", FTP_BINARY, 100); // while ($ret == FTP_MOREDATA) { // // // ... // // // Continue downloading... // $ret = ftp_nb_continue($ftp); // } // [/php] // In the example above, newfile is 100 bytes smaller than README on the FTP server because we started reading at offset 100. If we didn't disable FTP_AUTOSEEK, the first 100 bytes of newfile would be '\0'. // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-nb-get.php // ========== FTP_NB_GET - END // SYNTAX: // int|false ftp_nb_get(FTP\Connection $ftp, string $local_filename, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0) return $return_ftp_nb_get; // int|false } // ============================== END // PHP_OTHER_FTP_FTP_NB_GET // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_NB_PUT // ============================== PUBLIC // ============================== ABOUT // Stores a file on the FTP server (non-blocking). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_nb_put() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ============================== USING CONSTANTS (1) // FTP_BINARY - ftp_nb_put() // ============================== CODE function php_other_ftp_ftp_nb_put($ftp, $remote_filename, $local_filename, $mode = FTP_BINARY, $offset = 0) { $return_ftp_nb_put = false; // ========== FTP_NB_PUT - BEGIN // ===== ABOUT // Stores a file on the FTP server (non-blocking) // ===== DESCRIPTION // ftp_nb_put() stores a local file on the FTP server. // The difference between this function and the ftp_put() is that this function uploads the file asynchronously, so your program can perform other operations while the file is being uploaded. // ===== SUPPORTED // PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_nb_put( // FTP\Connection $ftp, // string $remote_filename, // string $local_filename, // int $mode = FTP_BINARY, // int $offset = 0 // ): int|false // ===== CODE $return_ftp_nb_put = ftp_nb_put( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $remote_filename, // string remote_filename - The remote file path. $local_filename, // string local_filename - The local file path. $mode, // int mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. $offset // int offset - The position in the remote file to start uploading to. ); // Return Values // Returns FTP_FAILED or FTP_FINISHED or FTP_MOREDATA, or false on failure to open the local file. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // 7.3.0 - The mode parameter is now optional. Formerly it has been mandatory. // // [examples] // Examples // [example] // Example #1 ftp_nb_put() example // [php] // // // Initiate the Upload // $ret = ftp_nb_put($ftp, "test.remote", "test.local", FTP_BINARY); // while ($ret == FTP_MOREDATA) { // // // Do whatever you want // echo "."; // // // Continue uploading... // $ret = ftp_nb_continue($ftp); // } // if ($ret != FTP_FINISHED) { // echo "There was an error uploading the file..."; // exit(1); // } // [/php] // [/example] // [example] // Example #2 Resuming an upload with ftp_nb_put() // [php] // // // Initiate // $ret = ftp_nb_put($ftp, "test.remote", "test.local", // FTP_BINARY, ftp_size("test.remote")); // // OR: $ret = ftp_nb_put($ftp, "test.remote", "test.local", // // FTP_BINARY, FTP_AUTORESUME); // // while ($ret == FTP_MOREDATA) { // // // Do whatever you want // echo "."; // // // Continue uploading... // $ret = ftp_nb_continue($ftp); // } // if ($ret != FTP_FINISHED) { // echo "There was an error uploading the file..."; // exit(1); // } // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-nb-put.php // ========== FTP_NB_PUT - END // SYNTAX: // int|false ftp_nb_put(FTP\Connection $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0) return $return_ftp_nb_put; // int|false } // ============================== END // PHP_OTHER_FTP_FTP_NB_PUT // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_NLIST // ============================== PUBLIC // ============================== ABOUT // Returns a list of files in the given directory. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_nlist() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_nlist($ftp, $directory) { $return_ftp_nlist = false; // ========== FTP_NLIST - BEGIN // ===== ABOUT // Returns a list of files in the given directory // ===== DESCRIPTION // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_nlist(FTP\Connection $ftp, string $directory): array|false // ===== CODE $return_ftp_nlist = ftp_nlist( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $directory // string directory - The directory to be listed. This parameter can also include arguments, eg. ftp_nlist($ftp, "-la /your/dir");. Note that this parameter isn't escaped so there may be some issues with filenames containing spaces and other characters. ); // Return Values // Returns an array of filenames from the specified directory on success or false on error. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_nlist() example // [php] // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // get contents of the current directory // $contents = ftp_nlist($ftp, "."); // // // output $contents // var_dump($contents); // // [/php] // The above example will output something similar to: // [result] // array(3) { // [0]=> // string(11) "public_html" // [1]=> // string(10) "public_ftp" // [2]=> // string(3) "www" // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-nlist.php // ========== FTP_NLIST - END // SYNTAX: // array|false ftp_nlist(FTP\Connection $ftp, string $directory) return $return_ftp_nlist; // array|false } // ============================== END // PHP_OTHER_FTP_FTP_NLIST // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_PASV // ============================== PUBLIC // ============================== ABOUT // Turns passive mode on or off. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_pasv() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_pasv($ftp, $enable) { $return_ftp_pasv = false; // ========== FTP_PASV - BEGIN // ===== ABOUT // Turns passive mode on or off // ===== DESCRIPTION // ftp_pasv() turns on or off passive mode. In passive mode, data connections are initiated by the client, rather than by the server. It may be needed if the client is behind firewall. // Please note that ftp_pasv() can only be called after a successful login or otherwise it will fail. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_pasv(FTP\Connection $ftp, bool $enable): bool // ===== CODE $return_ftp_pasv = ftp_pasv( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $enable // bool enable - If true, the passive mode is turned on, else it's turned off. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_pasv() example // [php] // $file = 'somefile.txt'; // $remote_file = 'readme.txt'; // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // turn passive mode on // ftp_pasv($ftp, true); // // // upload a file // if (ftp_put($ftp, $remote_file, $file, FTP_ASCII)) { // echo "successfully uploaded $file\n"; // } else { // echo "There was a problem while uploading $file\n"; // } // // // close the connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-pasv.php // ========== FTP_PASV - END // SYNTAX: // bool ftp_pasv(FTP\Connection $ftp, bool $enable) return $return_ftp_pasv; // bool } // ============================== END // PHP_OTHER_FTP_FTP_PASV // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_PUT // ============================== PUBLIC // ============================== ABOUT // Uploads a file to the FTP server. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_put() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== USING CONSTANTS (1) // FTP_BINARY - ftp_put() // ============================== CODE function php_other_ftp_ftp_put($ftp, $remote_filename, $local_filename, $mode = FTP_BINARY, $offset = 0) { $return_ftp_put = false; // ========== FTP_PUT - BEGIN // ===== ABOUT // Uploads a file to the FTP server // ===== DESCRIPTION // ftp_put() stores a local file on the FTP server. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_put( // FTP\Connection $ftp, // string $remote_filename, // string $local_filename, // int $mode = FTP_BINARY, // int $offset = 0 // ): bool // ===== CODE $return_ftp_put = ftp_put( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $remote_filename, // string remote_filename - The remote file path. $local_filename, // string local_filename - The local file path. $mode, // int mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. $offset // int offset - The position in the remote file to start uploading to. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // 7.3.0 - The mode parameter is now optional. Formerly it has been mandatory. // // [examples] // Examples // [example] // Example #1 ftp_put() example // [php] // $file = 'somefile.txt'; // $remote_file = 'readme.txt'; // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // upload a file // if (ftp_put($ftp, $remote_file, $file, FTP_ASCII)) { // echo "successfully uploaded $file\n"; // } else { // echo "There was a problem while uploading $file\n"; // } // // // close the connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-put.php // ========== FTP_PUT - END // SYNTAX: // bool ftp_put(FTP\Connection $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0) return $return_ftp_put; // bool } // ============================== END // PHP_OTHER_FTP_FTP_PUT // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_PWD // ============================== PUBLIC // ============================== ABOUT // Returns the current directory name. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_pwd() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_pwd($ftp) { $return_ftp_pwd = false; // ========== FTP_PWD - BEGIN // ===== ABOUT // Returns the current directory name // ===== DESCRIPTION // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_pwd(FTP\Connection $ftp): string|false // ===== CODE $return_ftp_pwd = ftp_pwd( $ftp // FTP\Connection ftp - An FTP\Connection instance. ); // Return Values // Returns the current directory name or false on error. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_pwd() example // [php] // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // change directory to public_html // ftp_chdir($ftp, 'public_html'); // // // print current directory // echo ftp_pwd($ftp); // /public_html // // // close the connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-pwd.php // ========== FTP_PWD - END // SYNTAX: // string|false ftp_pwd(FTP\Connection $ftp) return $return_ftp_pwd; // string|false } // ============================== END // PHP_OTHER_FTP_FTP_PWD // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_QUIT // ============================== PUBLIC // ============================== ABOUT // Closes an FTP connection. // // ftp_quit - Alias of ftp_close(). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_quit() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_quit($ftp) { $return_ftp_quit = false; // ========== FTP_QUIT - BEGIN // ===== ABOUT // ftp_quit - Alias of ftp_close() // ===== DESCRIPTION // This function is an alias of: ftp_close(). // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ===== CODE $return_ftp_quit = ftp_quit( $ftp // FTP\Connection ftp ); // Return // bool // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-quit.php // ========== FTP_QUIT - END // ========== FTP_CLOSE - BEGIN // ===== ABOUT // Closes an FTP connection // ===== DESCRIPTION // ftp_close() closes the given link identifier and releases the resource. // Note: After calling this function, you can no longer use the FTP connection and must create a new one with ftp_connect(). // ===== SUPPORTED // PHP_4 >= PHP_4_2_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_close(FTP\Connection $ftp): bool // ===== CODE // $return_ftp_close = ftp_close( // $ftp // FTP\Connection ftp - An FTP\Connection instance. // ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_close() example // [php] // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // print the current directory // echo ftp_pwd($ftp); // // // close this connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-close.php // ========== FTP_CLOSE - END // SYNTAX: // bool ftp_quit(FTP\Connection $ftp) return $return_ftp_quit; // bool } // ============================== END // PHP_OTHER_FTP_FTP_QUIT // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_RAW // ============================== OFFLINE // ============================== ABOUT // Sends an arbitrary command to an FTP server. // ============================== SUPPORT // PHP_5 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_raw() - PHP_5, PHP_7, PHP_8 // ============================== CODE /* function php_other_ftp_ftp_raw($ftp, $command) { $return_ftp_raw = null; // ========== FTP_RAW - BEGIN // ===== ABOUT // Sends an arbitrary command to an FTP server // ===== DESCRIPTION // Sends an arbitrary command to the FTP server. // ===== SUPPORTED // PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_raw(FTP\Connection $ftp, string $command): ?array // ===== CODE $return_ftp_raw = ftp_raw( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $command // string command - The command to execute. ); // Return Values // Returns the server's response as an array of strings, or null on failure. No parsing is performed on the response string, nor does ftp_raw() determine if the command succeeded. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 Using ftp_raw() to login to an FTP server manually. // [php] // $ftp = ftp_connect("ftp.example.com"); // // // This is the same as: // // ftp_login($ftp, "joeblow", "secret"); // ftp_raw($ftp, "USER joeblow"); // ftp_raw($ftp, "PASS secret"); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-raw.php // ========== FTP_RAW - END // SYNTAX: // array ftp_raw(FTP\Connection $ftp, string $command) return $return_ftp_raw; // array } */ // ============================== END // PHP_OTHER_FTP_FTP_RAW // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_RAWLIST // ============================== PUBLIC // ============================== ABOUT // Returns a detailed list of files in the given directory. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_rawlist() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_rawlist($ftp, $directory, $recursive = false) { $return_ftp_rawlist = false; // ========== FTP_RAWLIST - BEGIN // ===== ABOUT // Returns a detailed list of files in the given directory // ===== DESCRIPTION // ftp_rawlist() executes the FTP LIST command, and returns the result as an array. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_rawlist(FTP\Connection $ftp, string $directory, bool $recursive = false): array|false // ===== CODE $return_ftp_rawlist = ftp_rawlist( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $directory, // string directory - The directory path. May include arguments for the LIST command. $recursive // bool recursive - If set to true, the issued command will be LIST -R. ); // Return Values // Returns an array where each element corresponds to one line of text. Returns false when passed directory is invalid. // The output is not parsed in any way. The system type identifier returned by ftp_systype() can be used to determine how the results should be interpreted. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_rawlist() example // [php] // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // get the file list for / // $buff = ftp_rawlist($ftp, '/'); // // // close the connection // ftp_close($ftp); // // // output the buffer // var_dump($buff); // [/php] // The above example will output something similar to: // [result] // array(3) { // [0]=> // string(65) "drwxr-x--- 3 vincent vincent 4096 Jul 12 12:16 public_ftp" // [1]=> // string(66) "drwxr-x--- 15 vincent vincent 4096 Nov 3 21:31 public_html" // [2]=> // string(73) "lrwxrwxrwx 1 vincent vincent 11 Jul 12 12:16 www -> public_html" // } // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-rawlist.php // ========== FTP_RAWLIST - END // SYNTAX: // array|false ftp_rawlist(FTP\Connection $ftp, string $directory, bool $recursive = false) return $return_ftp_rawlist; // array|false } // ============================== END // PHP_OTHER_FTP_FTP_RAWLIST // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_RENAME // ============================== PUBLIC // ============================== ABOUT // Renames a file or a directory on the FTP server. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_rename() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_rename($ftp, $from, $to) { $return_ftp_rename = false; // ========== FTP_RENAME - BEGIN // ===== ABOUT // Renames a file or a directory on the FTP server // ===== DESCRIPTION // ftp_rename() renames a file or a directory on the FTP server. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_rename(FTP\Connection $ftp, string $from, string $to): bool // ===== CODE $return_ftp_rename = ftp_rename( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $from, // string from - The old file/directory name. $to // string to - The new name. ); // Return Values // Returns true on success or false on failure. Upon failure (such as attempting to rename a non-existent file), an E_WARNING error will be emitted. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_rename() example // [php] // $old_file = 'somefile.txt.bak'; // $new_file = 'somefile.txt'; // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // try to rename $old_file to $new_file // if (ftp_rename($ftp, $old_file, $new_file)) { // echo "successfully renamed $old_file to $new_file\n"; // } else { // echo "There was a problem while renaming $old_file to $new_file\n"; // } // // // close the connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-rename.php // ========== FTP_RENAME - END // SYNTAX: // bool ftp_rename(FTP\Connection $ftp, string $from, string $to) return $return_ftp_rename; // bool } // ============================== END // PHP_OTHER_FTP_FTP_RENAME // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_RMDIR // ============================== PUBLIC // ============================== ABOUT // Removes a directory. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_rmdir() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_rmdir($ftp, $directory) { $return_ftp_rmdir = false; // ========== FTP_RMDIR - BEGIN // ===== ABOUT // Removes a directory // ===== DESCRIPTION // Removes the specified directory on the FTP server. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_rmdir(FTP\Connection $ftp, string $directory): bool // ===== CODE $return_ftp_rmdir = ftp_rmdir( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $directory // string directory - The directory to delete. This must be either an absolute or relative path to an empty directory. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_rmdir() example // [php] // // $dir = 'www/'; // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // try to delete the directory $dir // if (ftp_rmdir($ftp, $dir)) { // echo "Successfully deleted $dir\n"; // } else { // echo "There was a problem while deleting $dir\n"; // } // // ftp_close($ftp); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-rmdir.php // ========== FTP_RMDIR - END // SYNTAX: // bool ftp_rmdir(FTP\Connection $ftp, string $directory) return $return_ftp_rmdir; // bool } // ============================== END // PHP_OTHER_FTP_FTP_RMDIR // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_SET_OPTION // ============================== PUBLIC // ============================== ABOUT // Set miscellaneous runtime FTP options. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_set_option() - PHP_4 >= PHP_4_2_0, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_set_option($ftp, $option, $value) { $return_ftp_set_option = false; // ========== FTP_SET_OPTION - BEGIN // ===== ABOUT // Set miscellaneous runtime FTP options // ===== DESCRIPTION // This function controls various runtime options for the specified FTP connection. // ===== SUPPORTED // PHP_4 >= PHP_4_2_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_set_option(FTP\Connection $ftp, int $option, int|bool $value): bool // ===== CODE $return_ftp_set_option = ftp_set_option( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $option, // int option - Currently, the following options are supported: // // Supported runtime FTP options // FTP_TIMEOUT_SEC - Changes the timeout in seconds used for all network related functions. value must be an integer that is greater than 0. The default timeout is 90 seconds. // FTP_AUTOSEEK - When enabled, GET or PUT requests with a resumepos or startpos parameter will first seek to the requested position within the file. This is enabled by default. // FTP_USEPASVADDRESS - When disabled, PHP will ignore the IP address returned by the FTP server in response to the PASV command and instead use the IP address that was supplied in the ftp_connect(). value must be a boolean. $value // int|bool value - This parameter depends on which option is chosen to be altered. ); // Return Values // Returns true if the option could be set; false if not. A warning message will be thrown if the option is not supported or the passed value doesn't match the expected value for the given option. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_set_option() example // [php] // // Set the network timeout to 10 seconds // ftp_set_option($ftp, FTP_TIMEOUT_SEC, 10); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-set-option.php // ========== FTP_SET_OPTION - END // SYNTAX: // bool ftp_set_option(FTP\Connection $ftp, int $option, int|bool $value) return $return_ftp_set_option; // bool } // ============================== END // PHP_OTHER_FTP_FTP_SET_OPTION // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_SITE // ============================== PUBLIC // ============================== ABOUT // Sends a SITE command to the server. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_site() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_site($ftp, $command) { $return_ftp_site = false; // ========== FTP_SITE - BEGIN // ===== ABOUT // Sends a SITE command to the server // ===== DESCRIPTION // ftp_site() sends the given SITE command to the FTP server. // SITE commands are not standardized, and vary from server to server. They are useful for handling such things as file permissions and group membership. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_site(FTP\Connection $ftp, string $command): bool // ===== CODE $return_ftp_site = ftp_site( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $command // string command - The SITE command. Note that this parameter isn't escaped so there may be some issues with filenames containing spaces and other characters. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 Sending a SITE command to an ftp server // [php] // // Connect to FTP server // $ftp = ftp_connect('ftp.example.com'); // if (!$ftp) die('Unable to connect to ftp.example.com'); // // // Login as "user" with password "pass" // if (!ftp_login($ftp, 'user', 'pass')) die('Error logging into ftp.example.com'); // // // Issue: "SITE CHMOD 0600 /home/user/privatefile" command to ftp server // if (ftp_site($ftp, 'CHMOD 0600 /home/user/privatefile')) { // echo "Command executed successfully.\n"; // } else { // die('Command failed.'); // } // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-site.php // ========== FTP_SITE - END // SYNTAX: // bool ftp_site(FTP\Connection $ftp, string $command) return $return_ftp_site; // bool } // ============================== END // PHP_OTHER_FTP_FTP_SITE // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_SIZE // ============================== PUBLIC // ============================== ABOUT // Returns the size of the given file. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_size() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_size($ftp, $filename) { $return_ftp_size = 0; // ========== FTP_SIZE - BEGIN // ===== ABOUT // Returns the size of the given file // ===== DESCRIPTION // ftp_size() returns the size of the given file in bytes. // Note: Not all servers support this feature. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_size(FTP\Connection $ftp, string $filename): int // ===== CODE $return_ftp_size = ftp_size( $ftp, // FTP\Connection ftp - An FTP\Connection instance. $filename // string filename - The remote file. ); // Return Values // Returns the file size on success, or -1 on error. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_size() example // [php] // // $file = 'somefile.txt'; // // // set up basic connection // $ftp = ftp_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // // get the size of $file // $res = ftp_size($ftp, $file); // // if ($res != -1) { // echo "size of $file is $res bytes"; // } else { // echo "couldn't get the size"; // } // // // close the connection // ftp_close($ftp); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-size.php // ========== FTP_SIZE - END // SYNTAX: // int ftp_size(FTP\Connection $ftp, string $filename) return $return_ftp_size; // int } // ============================== END // PHP_OTHER_FTP_FTP_SIZE // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_SSL_CONNECT // ============================== PUBLIC // ============================== ABOUT // Opens a Secure SSL-FTP connection. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_ssl_connect() - PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_ssl_connect($hostname, $port = 21, $timeout = 90) { $return_ftp_ssl_connect = false; // ========== FTP_SSL_CONNECT - BEGIN // ===== ABOUT // Opens a Secure SSL-FTP connection // ===== DESCRIPTION // ftp_ssl_connect() opens an explicit SSL-FTP connection to the specified hostname. That implies that ftp_ssl_connect() will succeed even if the server is not configured for SSL-FTP, or its certificate is invalid. Only when ftp_login() is called, the client will send the appropriate AUTH FTP command, so ftp_login() will fail in the mentioned cases. // Note: Why this function may not exist // Before PHP 7.0.0, ftp_ssl_connect() was only available if both the ftp module and the OpenSSL support have been built statically into php; this means that on Windows this function had been undefined in the official PHP builds. To have this function available on Windows, it had been necessary to compile own PHP binaries. // Note: ftp_ssl_connect() is not intended for use with sFTP. To use sFTP with PHP, please see ssh2_sftp(). // ===== SUPPORTED // PHP_4 >= PHP_4_3_0, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_ssl_connect(string $hostname, int $port = 21, int $timeout = 90): FTP\Connection|false // ===== CODE $return_ftp_ssl_connect = ftp_ssl_connect( $hostname, // string hostname - The FTP server address. This parameter shouldn't have any trailing slashes and shouldn't be prefixed with ftp://. $port, // int port - This parameter specifies an alternate port to connect to. If it is omitted or set to zero, then the default FTP port, 21, will be used. $timeout // int timeout - This parameter specifies the timeout for all subsequent network operations. If omitted, the default value is 90 seconds. The timeout can be changed and queried at any time with ftp_set_option() and ftp_get_option(). ); // Return Values // Returns an FTP\Connection instance on success, or false on failure. // // Changelog // Version - Description // 8.1.0 - Returns an FTP\Connection instance now; previously, a resource was returned. // // [examples] // Examples // [example] // Example #1 ftp_ssl_connect() example // [php] // // // set up basic ssl connection // $ftp = ftp_ssl_connect($ftp_server); // // // login with username and password // $login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); // // if (!$login_result) { // // PHP will already have raised an E_WARNING level message in this case // die("can't login"); // } // // echo ftp_pwd($ftp); // // // close the ssl connection // ftp_close($ftp); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-ssl-connect.php // ========== FTP_SSL_CONNECT - END // SYNTAX: // FTP\Connection|false ftp_ssl_connect(string $hostname, int $port = 21, int $timeout = 90) return $return_ftp_ssl_connect; // FTP\Connection|false } // ============================== END // PHP_OTHER_FTP_FTP_SSL_CONNECT // ============================== // ============================== BEGIN // PHP_OTHER_FTP_FTP_SYSTYPE // ============================== PUBLIC // ============================== ABOUT // Returns the system type identifier of the remote FTP server. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ftp_systype() - PHP_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_other_ftp_ftp_systype($ftp) { $return_ftp_systype = false; // ========== FTP_SYSTYPE - BEGIN // ===== ABOUT // Returns the system type identifier of the remote FTP server // ===== DESCRIPTION // Returns the system type identifier of the remote FTP server. // ===== SUPPORTED // PHP_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ftp_systype(FTP\Connection $ftp): string|false // ===== CODE $return_ftp_systype = ftp_systype( $ftp // FTP\Connection ftp - An FTP\Connection instance. ); // Return Values // Returns the remote system type, or false on error. // // Changelog // Version - Description // 8.1.0 - The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected. // // [examples] // Examples // [example] // Example #1 ftp_systype() example // [php] // // // ftp connection // $ftp = ftp_connect('ftp.example.com'); // ftp_login($ftp, 'user', 'password'); // // // get the system type // if ($type = ftp_systype($ftp)) { // echo "Example.com is powered by $type\n"; // } else { // echo "Couldn't get the systype"; // } // // [/php] // The above example will output something similar to: // [result] // Example.com is powered by UNIX // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/function.ftp-systype.php // ========== FTP_SYSTYPE - END // SYNTAX: // string|false ftp_systype(FTP\Connection $ftp) return $return_ftp_systype; // string|false } // ============================== END // PHP_OTHER_FTP_FTP_SYSTYPE // ============================== // ============================== END // PHP_OTHER_FTP // ============================== ?>