承接 artdarek/force-download 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

artdarek/force-download

Composer 安装命令:

composer require artdarek/force-download

包简介

Force File Download for PHP

README 文档

README

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

Installation

Add artdarek/force-download to your composer.json file:

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

Use composer to install this package.

$ composer update

Usage

Create file called ie. 'download.php'.

Include artdarek/force-download library:

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

or if you are using composer autoloader include this instead:

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

after this simply add:

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

you can also pass your own config to allow only some file types to be downloadable:

	// 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.

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

See examples directory for more usage examples :D

统计信息

  • 总下载量: 71
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固