UltraMega Blog

PHP File Downloads

PHP can be used to securely control access to file downloads. This tutorial will show how you can send file through a PHP script and limit the download rate. The function we will write accepts the path to the file to send and optionally a rate in kB/s to limit the transfer speed. The function should also be able to handle range headers from clients that allow stopping and resuming downloads.


Working With Directories in PHP

PHP offers some built in file system related functions that allow you to work directly with files and directories. This tutorial will focus on working with directories. It will explain how to open and list the contents of directories, which is actually pretty easy to do.

The process goes pretty much like this: open a directory, read the directory in a loop, check each entry to see if it is a file or directory, display each accordingly, then close the directory.