Bug #16969 Updated: Improper readfile filesize after download

From: Date: Thu, 02 May 2002 16:53:51 +0000
Subject: Bug #16969 Updated: Improper readfile filesize after download
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-6760@lists.php.net to get a copy of this message
ID: 16969 Updated by: wez@php.net Reported By: fred.malone@planitcabnetware.com -Status: Open +Status: Feedback Bug Type: IIS related Operating System: Windows 2000 Server PHP Version: 4.2.0 New Comment: Does the end of your script have a blank line after the ?>, or do you have an auto_prepend file or some other include file that has this?? Previous Comments: ------------------------------------------------------------------------ [2002-05-02 12:43:08] fred.malone@planitcabnetware.com Also, I checked the file size using the filesave function and it reports the correct file size. I have tried this using MSIE 6 and Netscape 6. I tried this from both WinXP and Win2000 workstations. My function looks like: function DownloadFile($filename) { // Check filename if (empty($filename)) { return FALSE; } // Create download file name to be displayed to user $saveasname = basename($filename); header('Content-Type: application/octet-stream'); header('Content-Length: '.filesize($filename)); $browser = $_SERVER["HTTP_USER_AGENT"]; if (preg_match('/MSIE 5.5/', $browser) || preg_match('/MSIE 6.0/', $browser)) { header('Content-Disposition: filename="'.$saveasname.'"'); } else { header('Content-Disposition: attachment; filename="'.$saveasname.'"'); } header('Content-Transfer-Encoding: binary'); // Output file readfile($filename); // Done return TRUE; } ------------------------------------------------------------------------ [2002-05-02 12:19:05] fred.malone@planitcabnetware.com On my NT Srv 4 with IIS 4 and 2000 Srv with IIS 5 I have had the same problem. Running PHP 4.2, when I use readfile to download a binary file, the file size is two bytes greater than the original file size. The file is an executable file, and it has happened to more than one file. If you need any other information, let me know. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16969&edit=1

« previous php.bugs (#6760) next »