Code Monkey home page Code Monkey logo

ftp-download-php's Introduction

Download File Through FTP

Easy-to-use PHP functions to download files through FTP.

Usage

Copy the files from the build directory to your project.

Example

require_once 'downloadFileThroughFtp.php';

downloadFileThroughFtp(
    'anonymous',                   // user name
    '',                            // password
    'speedtest.tele2.net',         // host
    '1KB.zip',                     // remote path
    'path/to/your/local/directory' // local directory path
);

It’s good practice to avoid hard-coding your connection information in your production code. Instead, you can use a configuration file that your code reads.

Example: using configuration

config.php

define( 'FTP_USERNAME', 'username' );
define( 'FTP_PASSWORD', '*********' );
define( 'FTP_HOST', 'example.com' );
define( 'FTP_REMOTE_PATH', 'remote/path/to/file' );
define( 'LOCAL_DIRECTORY_PATH', 'path/to/local/directory' );

your-script.php

require_once 'config.php';
require_once 'downloadFileThroughFtp.php';

downloadFileThroughFtp(
    FTP_USERNAME,
    FTP_PASSWORD,
    FTP_HOST,
    FTP_REMOTE_PATH,
    FTP_LOCAL_DIRECTORY_PATH
);

Building and Testing

You’ll need Composer to build and test.

Installing Dependencies

php composer.phar install

Run Tests

vendor/bin/phpunit src

The tests will download a 1 kB zip file. You can change the FTP settings in src/config-test.php. See test FTP server for other files you can download. Of course, you can, for example, also change the settings to test your own FTP server, or adjust to your liking.

Build Project

vendor/bin/phing

License

MIT © Frederik Krautwald

ftp-download-php's People

Contributors

frikki avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.