Hello guys,
I have a force-download script that should force a download of binary files.
Now the weird thing is that nomatter what I try that it adds 2 newlines at the top of the output.
The files are binary image files like jpeg and eps, but also some documents.
//database connection
require_once("includes/dbc.php");
//SPE class library
require_once("includes/lib-spe.php");
//Application general configuration file
require_once("includes/config.php");
session_start();
if(!intval($REQUEST['fileid'])>0) header('Location: ?content=library');
$fileinfo = lib_get_fileinfo(intval($REQUEST['fileid']));
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // some day in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Content-type: application/x-download");
header("Content-Disposition: attachment; filename=\"" . $fileinfo['filename'] . "\"");
header("Content-Transfer-Encoding: binary");
$loadfile = LIBSTORAGE . $fileinfo['filelocation'];
$handle = fopen($loadfile,"rb");
print fread($handle, filesize($loadfile));
fclose($handle);
that's my code, I tried opening the file in binary mode by forcing it, but nothing helps.
I also used fpassthru() but the newlines keep appearing rendering the downloaded file corrupt until I remove the newlines by hand from the downloaded file.
Please advise