File Download Script

September 19th, 2006  –  Category: PHP Scripts  –  15 Comments »

  • Share/Bookmark

This file downloading script will allow you to set up a download area on your website which links to files which don’t exist physically on the site. Rather, the files to be downloaded can exist in an alternate location. It is actually the system in use right on this page for downloading these files.

Click here to read more about the person who created these resources and is offering them for you to use.

Requirements: PHP

Download: Click Here

Website Hosting

If you’re looking for somewhere to host your own web creation, we would highly recommend DreamHost. Offering 167 Gig’s of storage space, 1.6 TB of bandwidth, PHP, MySQL and a host of other features, they’ll most likely be more than adequate for your website needs. And with a 97 day money back guarantee you can’t go wrong! Visit DreamHost for more information about what they offer.

And now, we’re offering $50 OFF coupons as a special benefit to our website visitors. Click here for more information.

Email on Updates

You may wish to join our mailing list to receive email notifications of new things we add to the site. This includes new free php scripts, and other items that might be of use to you. Enter your email address and click submit, if you would like to receive these notifications.

You will receive a verification email from us, asking to verify whether or not you wish to receive these notifications. Be assured, we will do our best to keep your information confidential.
We will not distribute your email address to anyone else.

Related Reading:

PHP Object-Oriented Solutions
Beginning PHP and MySQL: From Novice to Professional, Third Edition
Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide
PHP Solutions: Dynamic Web Design Made Easy

15 Responses to “File Download Script”

  1. Rick McCoy Says:

    I’m trying out your dl.php script but having problems. Will not find file. I’ve hard-coded the location to be sure. Simply tells me the file doesn’t exist. Any suggestions?

    http://www.ChristianImageLibrary.com/dl.php?filename=frost.zip

  2. Zain Says:

    I am having the exact same issue as Rick. It cannot find the file to be downloaded. The scrit is in the site root in a folder of its own, the files are in a seperate folder in the root as well (for purposes of testing the script), so the path should be:

    $download_path = “$DOCUMENT_ROOT/folder_containing_files”;

    The files in the secure folder are such as:
    newsletter.pdf
    somearchive.zip

    What are we doing wrong here? Please help.

    Thanks

  3. Admin Says:

    Hey guys,

    Thanks for trying the product. I suspect that the problem you are encountering may be related to how some PHP installs handle global variables. I’ve modified the code in the download slightly to account for this. You can also modify your own installations to use the following download path:
    $download_path = $_SERVER['DOCUMENT_ROOT'] . “/folder_containing_files”;

    Thanks for letting me know about the problem.

  4. tim Says:

    Hey James,
    Can the download path be set to a URL? I don’t want to use a path because of securty issues and some of the files will be on a different server that where the script is installed. Thanks

  5. Karim Says:

    Thanks for the script, just wish I could get it to work. All I ever get is “I’m sorry, the file doesn’t seem to exist.”

    Has anyone gotten this script to work?

  6. Steve Says:

    sorry guys… I downloaded it. installed it and it worked fine first time.

    Thanks for the script!

  7. Karim Says:

    Perhaps it’s the PHP install?

    Server Type FreeBSD
    Web Server Apache v1.3.37 (cgi)
    PHP 4.4.4

  8. Stuart Elliot Says:

    i have a collection of titles all go from 1 to 54

    eg old download path

    /Cds/1.rar
    /Cds/2.rar

    dl.php?filename=1.rar | 2.rar | 3.rar

    is there anyway of randomizing the download link or somat like that.

  9. Philippe Says:

    Hi James! Your script rocks!! works perfectly for me…

    Thanks a lot!!

  10. Richard Says:

    http://www.warkensoft.com/dl.php?filename=fileDownload.zip doesn’t work

  11. Admin Says:

    Hi Richard,

    Thanks for pointing it out. We just upgraded to a new server and the download script was broken. It has now been fixed.

  12. Matt Says:

    This small change allows for spaces in your file names.

    header(’Content-Disposition: attachment;filename=”‘.$filename.’”‘);

  13. collector Says:

    Nice script, not overloaded with useless features. But…
    You should escape filename in the script. Currently script opens whole site for hacker attack.
    You could also add hotlinking protection, like it is done in the following script
    http://www.zubrag.com/scripts/download.php

    This would make your script even more powerful.

  14. petter Says:

    Can’t see how this script would work with files on a remote server?

  15. stephanie Says:

    The filename when called from browser is case-sensitive.
    so dl.php?filename=btn.JPG is totally different than
    dl.php?filename=BTN.jpg

    In case any newbies can’t get this script to work it is worth pointing out.

Feedback



Other Information:

Programming Related

Articles we've written related to the topic of PHP Programming.


Website Development Tips

Tips and strategies related to the development of great websites.


General Information & Resources

General information and resources from WarkenSoft Productions.