In systems like that developed above, large files present some unique challenges to the developer. I'll explain these here briefly, but fully-developed solutions to these problems are beyond the scope of this book.
By default, MySQL does not accept commands (packets) that are longer than 1MB. This default puts a reasonably severe limit on the maximum file size you can store, unless you're prepared to write your file data in 1MB chunks, using an INSERT followed by several UPDATEs. You can increase the maximum packet size by setting the max_allowed_packet option in your my.cnf (or my.ini) file. Refer to the MySQL manual for more information about this issue.
PHP is configured by default to kill PHP scripts that run for more than 30 seconds. For large downloads over slow connections, this limit will be reached fairly quickly! Use PHP's set_time_limit function to set an appropriate limit for the download to occur, or simply set the time limit to zero, which allows the script to run to completion, however long it takes. Don't do this unless you're positive your script will always terminate, and not run into an infinite loop!