I have a problem about force-downloading,
the download process goes fine, it's more of the encoding part (in my assumption).
here is th code:
header('Content-Description: File Transfer');
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-Length: ".filesize($file));
header("Content-Disposition: attachment; filename=".basename($file)."");
if ( readfile($file) !== false ) {
logActivity("Some log stuff");
if ( $_GET['remove_after_download']==true || $_GET['remove_after_download']=="true" ) {
unlink( $file );
}
}
basically, after the script, i get a file that is different from the original file -- it has an additional "\n" character at the beginning of the file. And this character became very detrimental to some of the files that i want them to download. Does anyone ever hit this kind of problem? Or anyone know whhere the "\n" came from?
2) This could be related to the above question. Is it possible execute any php scripts after the method call readfile? Because as you see in the code, I was trying to log the activity, and remove the file after download. Apparently, none of them happened... anyone know why?