counting downloaded files
| From: | Adriaan Nel | Date: | Tue, 10 Feb 2004 13:58:49 +0000 |
| Subject: | counting downloaded files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-177281@lists.php.net to get a copy of this message | ||
Hi,
I am using the following piece of code, to download files, but the files are
allways corrupt...what am I doing wrong?
if ($submit) {
$full_filename = $_POST[full_filename];
$filename = $_POST[filename];
$dir = $_POST['dir'];
$size = $_POST[size];
$id = $_POST[id];
if((file_exists($full_filename)) && (substr(decoct(fileperms($dir)),-1) >=
4)) {
header("Content-type: ". "application/exe");
header("Content-Disposition: " . "attachment" . ";
filename=\"".$filename)."\"";
header("Content-Length: ".$size);
$fp = readfile($full_filename, "r");
mysql_query ("INSERT INTO files_downloaded
VALUES('$id','$ip',NOW())",$db_connection) or die (mysql_error());
return $fp;
}
}
I need to use some kind of form element to initiate the download, as I need
to keep track of the number of downloads...
Thanks for you help in advance
Adriaan Nel