I have a download script that inserts data into a database table when someone downloads a file. For some reason, the insert is adding several linefeeds to the end of the file being downloaded even if I comment out the database code. If I remove the insert code everything works as expected. Can someone see what I’m doing wrong?
<?php
$php_scripts = '../../php/';
require $php_scripts . 'PDO_Connection_Select.php';
require $php_scripts . 'GetUserIpAddr.php';
function mydloader($l_filename=NULL)
{
$ip = GetUserIpAddr();
if (!$pdo = PDOConnect("foxclone_data"))
{
exit;
}
if( isset( $l_filename ) ) {
header('Content-Type: octet-stream');
header("Content-Disposition: attachment; filename={$l_filename}");
header('Pragma: no-cache');
header('Expires: 0');
readfile($l_filename);
$stmt = $pdo->prepare("INSERT INTO download (address, filename) VALUES (?, ?)");
$stmt->execute([$ip, $l_filename]) ;
}
else {
echo "isset failed";
}
}
mydloader($_GET["f"]);
Thanks in advance