hugsbrugs / php-ftp
PHP FTP Utilities
Installs: 13 460
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 5
Open Issues: 2
Requires
- hugsbrugs/php-string: ^1.0
This package is auto-updated.
Last update: 2024-10-20 01:51:56 UTC
README
PHP FTP Utilities
If you also need SFTP : php-sftp
Install
Install package with composer
composer require hugsbrugs/php-ftp
In your PHP code, load librairy
require_once __DIR__ . '/vendor/autoload.php'; use Hug\Ftp\Ftp as Ftp;
Usage
Test FTP connection
Ftp::test($server, $user, $password, $port = 21);
Check if a file exists on Ftp Server
Ftp::is_file($server, $user, $password, $remote_file, $port = 21);
Delete a file on remote FTP server
Ftp::delete($server, $user, $password, $remote_file, $port = 21);
Recursively deletes files and folder in given directory (If remote_path ends with a slash delete folder content otherwise delete folder itself)
Ftp::rmdir($server, $user, $password, $remote_path, $port = 21);
Recursively copy files and folders on remote FTP server (If local_path ends with a slash upload folder content otherwise upload folder itself)
Ftp::upload_dir($server, $user, $password, $local_path, $remote_path, $port = 21);
Download a file from remote Ftp server
Ftp::download($server, $user, $password, $remote_file, $local_file, $port = 21);
Download a directory from remote FTP server (If remote_dir ends with a slash download folder content otherwise download folder itself)
Ftp::download_dir($server, $user, $password, $remote_dir, $local_dir, $port = 21);
Rename a file on remote FTP server
Ftp::rename($server, $user, $password, $old_file, $new_file, $port = 21);
Create a directory on remote FTP server
Ftp::mkdir($server, $user, $password, $directory, $port = 21);
Create a file on remote FTP server
Ftp::touch($server, $user, $password, $remote_file, $content, $port = 21);
Upload a file on FTP server
Ftp::upload($server, $user, $password, $local_file, $remote_file = '', $port = 21);
List files on FTP server
Ftp::scandir($server, $user, $password, $path, $port = 21);
Get default login FTP directory aka pwd
Ftp::pwd($server, $user, $password, $port = 21);
Tests
Edit example/test.php with your FTP parameters then run
php example/test.php
To Do
PHPUnit Tests
Author
Hugo Maugey visit my website ;)