CodeCanyon MightyFtp 8276375
Script \ PHP Script \ Add-ons
Directory \ Library \ Rename \ Permissions \ Server \ Interact \ MightyFTP \ Change

PHP Script - MightyFtp 8276375 by house34 @ CodeCanyon

Script \ PHP Script \ Add-ons

Mighty FTP is simply the easiest way to interact with your FTP server with PHP on the web.
Mighty FTP is a powerful FTP client side library that wraps the complexities
of the core PHP FTP library and provides an intuitive api to interact with files on the FTP server.
With the library the user can get information about files, upload & download files, change file permissions,
rename files etc.

Intuitive Style
What makes the library so powerful is not so much the features that the library provides
but more so how a user can interact with the library.
This library will make it as easy to interact with files on any FTP server using PHP much in
the same way as jQuery revolutionized how Javascript developers can interact with the DOM.
Like jQuery MightyFTP utilizes a powerful design pattern called chaining which allows
developers to apply multiple interactions to a file on the FTP server with a single line of code.
Features of library

- Easy FTP File/Directory traversal. Much like XML Node Traversal.

- Access both FTP servers and secure FTP servers.

- Access any file using absolute locations.

- Upload files to a remote FTP directory.

- Download files from an FTP directory.

- Change FTP file permissions.

- Get detailed information about files/directories.

- Apply many operations to a file in a single line of code using chaining.

Core PHP FTP api vs Mighty FTP api
Presented below is an example of how easy it is to use the Mighty FTP Api vs the Core PHP FTP Api.
We have been tasked to rename a sub directory and change its permissions.

Using the Core PHP FTP Api

//Connect and Login
$conn_id = FTP_connect("sampleserver.com");
$login_result = FTP_login($conn_id, "sampleusername", "samplepassword");
$old_dir_name = 'olddirectoryname';
$new_dir_name = 'newdirectoryname';
//First attempt to rename the file. We are assuming that the current directory is root.
if (FTP_rename($conn_id, $old_dir_name, $new_dir_name)) {
echo "successfully renamed $old_dir_name to $new_dir_namen";
} else {
echo "There was a problem while renaming $old_dir_name to $new_dir_namen";
//Next change the file permissions.
if (FTP_chmod($conn_id, 0777, $new_dir_name) !== false) {
echo "$file chmoded successfully to 777n";
} else {
echo "could not chmod $new_dir_namen";

Using the MightyFTP Api

//Include MightyFTP/FTPClient.php
function renameAndChangePermissions()
//Create MightyFTPFTPClient on login to sampleserver.com
$mightyFTPClient = new MightyFTPFTPClient("sampleserver.com", new MightyFTPFTPCredentials("sampleuser", "samplepassword"));
//Get the root directory
$rootDirectory = $mightyFTPClient->getRootDirectory();
$rootChildren = $rootDirectory->getChildren();
//Once you have a reference to the directory you can rename and chmod the directory in a single line of code.
//If no exceptions have been thrown then assume that everything was successful
echo "Successfully renamed olddirectoryname to newdirectoryname and changed permissions of directory to 777";
catch(MightyFTPFTPException $ex)
//If an exception was thrown then print exception message.
echo $ex->message();

Last Update: 25 July 14; High Resolution: No; Compatible Browsers: IE6, IE7, IE8, IE9, IE10, IE11, Firefox, Safari, Opera, Chrome; Files Included: PHP; Software Version: PHP 5.3, PHP 5.4, PHP 5.5.

Keywords: chaining, download, easy, ftp, ftp client, ftps, intuitive, jquery, php, server, simple, upload.