Re: How can the Surfer download

From: Date: Thu, 24 Jan 2002 18:16:53 +0000
Subject: Re: How can the Surfer download
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-81928@lists.php.net to get a copy of this message
Todd- > When I use the following code, I am not asked if I want to Save the file > or Open it. Instead, the contents of the file are displayed in the > browser. I am sure that I have missed something simple!! > > Todd > > <?php > $len = filesize("test.pdf"); > header("Content-type: application/pdf"); > header("Content-Length: $len"); > header("Content-Disposition: attachment; filename=test.pdf"); > readfile("test.pdf"); > ?> The code you are showing should work... therefore it may be something to do with your browser. Try changing the Content-Type to something that there is no way you could have ever registered in your browser: header("Content-Type: x-this-is-a-test/for-php"); And see if that changes the way it handles it. Of course, application/pdf is the CORRECT MIME type, so if this NEW MIME type does solve the problem, you should attempt to fix your browser, and put the script back the way it was. If it doesn't fix anything, try using a different browser, or better yet, a different machine. Additionally, when working with this type of operation, the first time you hit the page, it will be cached (in it's incorrect form) in your browser. Therefore, after making these changes, you should dump the Disk and Memory cache in your browser, and close and restart your browser just to be safe. Daniel

« previous php.general (#81928) next »