File Download Script

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

  • Share

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 for the Web: Visual QuickStart Guide (4th Edition)PHP for the Web: Visual QuickStart Guide (4th Edition)With PHP for the World Wide Web, Fourth Edition: Visual QuickStart Guide, readers can start from the beginning to get a tour of the programming langua... Read More >
Beginning PHP and MySQL: From Novice to ProfessionalBeginning PHP and MySQL: From Novice to Professional

Beginning PHP and MySQL: From Novice to Professional, Fourth Edition is a major update of W. Jason Gilmore's authoritative book on PHP and MySQL. T... Read More >

PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)It hasn't taken Web developers long to discover that when it comes to creating dynamic, database-driven Web sites, MySQL and PHP provide a winning ope... Read More >

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

  16. rodan Says:

    Thanks for the script. I appreciate a tightly coded example that does the job nicely.

  17. asghar Says:

    Hello,
    It works for me great too,
    but i have a problem why it doesnt support files with space in the name?
    can any one plz help me?

  18. leon Says:

    this is to say thank u to u implementer of this script!
    thank u again ! i’ve tried it and succeed today,but this is not to mean that this was my first trial i’ve been trying for 3 months but 2day i’m very lucky to meet u guy.

    thank u!

  19. Probhat Says:

    Thanks a lot…I was facing lot of problems with my project…your codes rocks…!! great…

Feedback


Recommended:

Wordpress Themes the Top Rated and Most Useful Themes - Intro PriceWordpress Themes the Top Rated and Most Useful Themes - Intro PriceNote: Intro Price will be going up soon!

If you’re using Wordpress on your websites, you can’t afford to miss out on this exciting offe... Read More >
Build Your Own PHP FrameworkBuild Your Own PHP FrameworkThere's a lot of different PHP frameworks out there. Some are big some, are small. But I doubt they do things exactly the way you want it.

... Read More >
Building WordPress Sites for Newbies * Free Bonus Video Series on How to Make an Extra $365k Per Year OnlineBuilding WordPress Sites for Newbies * Free Bonus Video Series on How to Make an Extra $365k Per Year OnlineImportant Notice: Buy Today as there will be a probably price increase! Learn how to start building and creating websites and blog sites using WordPre... Read More >

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.