PHP FTP function usage tutorial_PHP tutorial
PHP FTP function usage tutorial
Introducing PHP FTPThis feature provides FTP clients with access to file servers via File Transfer Protocol (FTP).
The FTP function is used to open, log in and close links, as well as upload, download, rename, delete and get information about files from the file server. Not all FTP functions will work with every server or return the same results. The FTP function becomes available with PHP 3.
These functions are all for detailed access to FTP servers. If you only wish to read or write files on an FTP server, consider using wrapper ftp:// with the file functionality.
Install
The Windows version of PHP has built-in support for FTP extensions. Therefore, the FTP function will work automatically.
However, if you are running a Linux version of PHP, you will have to compile PHP with -enable-FTP (PHP4+) or -with-FTP (PHP3) to get the FTP functions to work.
PHP’s FTP function
PHP: Shows the earliest PHP version with supported features.
Function | Description | PHP |
---|---|---|
ftp_alloc() | Allocates space for a file to be uploaded to the FTP server | 5 |
ftp_cdup() | Changes the current directory to the parent directory on the FTP server | 3 |
ftp_chdir() | Changes the current directory on the FTP server | 3 |
ftp_chmod() | Sets permissions on a file via FTP | 5 |
ftp_close() | Closes an FTP connection | 4 |
ftp_connect() | Opens an FTP connection | 3 |
ftp_delete() | Deletes a file on the FTP server | 3 |
ftp_exec() | Executes a program/command on the FTP server | 4 |
ftp_fget() | Downloads a file from the FTP server and saves it to an open file | 3 |
ftp_fput() | Uploads from an open file and saves it to a file on the FTP server | 3 |
ftp_get_option() | Returns runtime behaviors of the FTP connection | 4 |
ftp_get() | Downloads a file from the FTP server | 3 |
ftp_login() | Logs on to an FTP connection | 3 |
ftp_mdtm() | Returns the last modified time of a specified file | 3 |
ftp_mkdir() | Creates a new directory on the FTP server | 3 |
ftp_nb_continue() | Continues retrieving/sending a file (non-blocking) | 4 |
ftp_nb_fget() | Downloads a file from the FTP server and saves it to an open file (non-blocking) | 4 |
ftp_nb_fput() | Uploads from an open file and saves it to a file on the FTP server (non-blocking) | 4 |
ftp_nb_get() | Downloads a file from the FTP server (non-blocking) | 4 |
ftp_nb_put() | Uploads a file to the FTP server (non-blocking) | 4 |
ftp_nlist() | Lists the files in a specified directory on the FTP server | 3 |
ftp_pasv() | Turns passive mode on or off | 3 |
ftp_put() | Uploads a file to the FTP server | 3 |
ftp_pwd() | Returns the current directory name | 3 |
ftp_quit() | Alias of ftp_close() | 3 |
ftp_raw() | Sends a raw command to the FTP server | 5 |
ftp_rawlist() | Returns a detailed list of files in the specified directory | 3 |
ftp_rename() | Renames a file or directory on the FTP server | 3 |
ftp_rmdir() | Removes a directory on the FTP server | 3 |
ftp_set_option() | Sets runtime options for the FTP connection | 4 |
ftp_site() | Sends a SITE command to the server | 3 |
ftp_size() | Returns the size of the specified file | 3 |
ftp_ssl_connect() | Opens a secure SSL-FTP connection | 4 |
ftp_systype() | Returns the system type identifier of the FTP server | 3 |
PHP FTP Constants
PHP: indicates the earliest version of PHP that supports the constant.
Constant | Description | PHP |
---|---|---|
FTP_ASCII | 3 | |
FTP_TEXT | 3 | |
FTP_BINARY | 3 | |
FTP_IMAGE | 3 | |
FTP_TIMEOUT_SEC | 3 | |
FTP_AUTOSEEK | 4 | |
FTP_AUTORESUME | Determine resume position and start position for get and put requests automatically | 4 |
FTP_FAILED | Asynchronous transfer has failed | 4 |
FTP_FINISHED | Asynchronous transfer has finished | 4 |
FTP_MOREDATA | Asynchronous transfer is still active | 4 |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
