Hi, I'm using fread and header to deliver files to my visitors. It works fine with jpg, mp3 etc, but zip and exe always end up being corrupted. I checked their filesize, and the delivered zip/exe is always 1byte larger than the original file. Here's a sniplet my code:
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header('Content-Description: File Transfer');
header("Content-Type: $mime");
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=' . basename($file));
readfile($file);
Anyone can advise? Thanks.