You've got two ways to do this...one with MySQL (safe & more reliable) the other without.
I can give you the "exact" script, but it'll take a while. Here's the pseudocodes anyways...
METHOD 1: Using MySQL
1) Enter in data for product. Upload zip or tar/gz file to server using PHP upload and file moving functions to any folder you want.
2) Insert the location of the file (starting from your web httpd default location), into the mysql data table.
3) When the user buys and downloads the product, load the file and hand it to them.
4) Make download records on your sql table (OPTIONAL)
METHOD 2
1) Enter in data for product. Upload zip or tar/gz file to server using PHP upload and file moving functions to a COMMON, specified where ALL downloads are stored there. Give the zip a special name or id.
2) When the user buys and downloads the product, load the file and hand it to them.
3) Make download records on your sql table (OPTIONAL)
If you want the code, or more specific stuff, just tell me