2017 © Pedro Peláez
 

library force-download

Force File Download for PHP

image

artdarek/force-download

Force File Download for PHP

  • Friday, December 12, 2014
  • by Artdarek
  • Repository
  • 1 Watchers
  • 0 Stars
  • 31 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 19 % Grown

The README.md

Force File Download for PHP

If on your page you place a link to file like "pdf" browser will automaticly open it, but what if you don't want that file to be opened, instead you just want user to be able to download this file. If so this package is a solution for you :D, (*1)


Installation

Add artdarek/force-download to your composer.json file:, (*2)

"require": {
  "artdarek/force-download": "dev-master"
}

Use composer to install this package., (*3)

$ composer update

Usage

Create file called ie. 'download.php'., (*4)

Include artdarek/force-download library:, (*5)

  // include composer autoloader 
  require 'ForceDownload.php';

or if you are using composer autoloader include this instead:, (*6)

  // include composer autoloader 
  require 'vendor/autoload.php';

after this simply add:, (*7)

  // initialize download
  $force = new Artdarek\ForceDownload();
  $force->download();

you can also pass your own config to allow only some file types to be downloadable:, (*8)

    // custom config
    $config = array(
    'allowed_extensions' => array(
      // archives
          'zip' => 'application/zip',
      // documents
          'pdf' => 'application/pdf',
      // images
          'gif' => 'image/gif',
          'png' => 'image/png',
          'jpg' => 'image/jpeg',
          'jpeg'=> 'image/jpeg',
    )
    );

  // initialize download
  $force = new Artdarek\ForceDownload($config);
  $force->download();

Done... now you can create a url that will directly start downloding specified file instead of opening it in the browser., (*9)

  <a href="download.php?dir=download_folder&file=example.pdf">Download</a>

See examples directory for more usage examples :D, (*10)

The Versions

12/12 2014

dev-master

9999999-dev https://github.com/artdarek/force-download

Force File Download for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar Artdarek

download file force download php file download file downloader

12/12 2014

1.0.1

1.0.1.0 https://github.com/artdarek/force-download

Force File Download for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar Artdarek

download file force download php file download file downloader

22/09 2014

1.0.0

1.0.0.0 https://github.com/artdarek/force-download

Force File Download for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar Artdarek

download file force download php file download file downloader