Browsing:PHP Download File Script – Free Must Have Class

PHP File download class will be helpful for developers and users to provide facility of “File Download” by hiding real file paths. Chip File Download Class which is written in PHP is very flexible and easy to use. The script triggers the download dialogue so that visitors can choose to download the file instead of opening it in the browser.

This is very useful PHP download script. You can use PHP file download script to avoid direct files downloads (hide real file paths), and to limit downloads to only some set of file types. Get free Demos of Framework and Zend PHP.

It is an easy to use force file download script, useful for sites that have different files and would like force people to download the files instead of having them run remotely off their web server. This can be applied to mp3′s, video clips, archives, docs, images, pdf files and more.

Features

Provide any file type for download

Flexible control over files type, which are being offered to download

A set of predefined mime type settings for most common file extensions

Built-in feature for detecting mime type automatically, if Mimetype or Fileinfo extension installed on the server

Hot-linking protection

Displays download dialogue

Download folder protection

Directory(s) containing files, within “download_path” support

Requirements

PHP5 or higher

Extension Requirements – Optional

Mimetype Extension

Fileinfo Extension

I have already given a full sample code in the download archive but i will also explain the usage of class online as simple as possible. I hope you will be able to use it within a little time.

Include class.chip_download.php

You have to include download file script in your file at the suitable position you think. I will recommend to use all code of this tutorial at the top of your page to avoid any output warning.

require_once("class.chip_download.php");

Variable: $download_path

Set $download_path variable. You should provide absolute path to the download directory. Windows example can be “E:/wamp/www/tutorialchip/download/”, where as Linux example can be “/home/tutorialchip/public_html/download/”.

Variable: $file

Set $file variable. You should provide file name in this variable. Example can be “nature.zip”, “nature.jpg” etc.

Array: $args

extension_check (boolean TRUE | FALSE): It is TRUE by default, It will give you a flexible control to offer particular files to download with this PHP download script. You can set it to FALSE, if you donot want to control over file types and willing to download all types of files.

referrer_check (boolean TRUE | FALSE): It is FALSE by default, It will provide you a flexible control over hot-linking. You have to set “referrer” after making it TRUE. It will allow download files from a server which will match “referrer” value only.

referrer (String): You have to set its value after setting “referrer_check” TRUE. An example of its value can be “tutorialchip.com” so download will only be offered from tutorialchip server request only.

Pre Download Hook

PHP download class will do its job, and provide you a Hook to execute your code or changes before throwing download stream to the users. You can check available options of Pre Download Hook by executing following code.