<?php
//File on server
$file = "Levy.dat";
//Filename when downloaded
$file2 = "Levy.jar";
//Using counter?
$counter = true;
//If true, counterfile:
$counterfilename = "Levy.txt";
// Headers for download:
header('Content-Type: application/octet-stream');
header("Content-Length: ".filesize($file));
header('Content-Disposition: attachment; filename="'.$file2.'"');
header('Content-Transfer-Encoding: binary');
readfile($file);
if(!$counter) exit;
@$counterfile = fopen($counterfilename,"r");
@$num = (int) fread($counterfile,filesize($counterfilename));
@fclose($counterfile);
@$counterfile = fopen($counterfilename,"w");
@$num++;
@fwrite($counterfile,$num);
@fclose($counterfile);
?>