PHP Download script for any filesize


/ Published in: PHP
Save to your folder(s)

By default Apache won't allow you to download a file over 2GB. This PHP script overcomes that along with some extra goodies.

The script will read from standard url path the file on the server to download and display the filesize along with a link to download it.

Setup:

1) Create a directory called "d" on the root of your website and name this script "index.php"

2) Create a .htaccess file with the following lines:

RewriteEngine On

RewriteBase /d/

RewriteCond %{REQUEST_DIRECTORY} !-d [NC]

RewriteRule ^(.*)$ index.php?f=$1 [L]

3) Craft a url in the format of: http://[website_url]/d/path/to/download/filename.dat

This will link to a file: http://[website_url]/path/to/download/filename.dat

If you want, you can also craft a url with a trailing "&" and it will automatically start downloading.

Example: http://[website_url]/path/to/download/filename.dat&

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.