outputting a pdf file to IE browser? POST/GET method bug or not?
| From: | gilles | Date: | Mon, 15 Jul 2002 17:18:32 +0000 |
| Subject: | outputting a pdf file to IE browser? POST/GET method bug or not? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-107732@lists.php.net to get a copy of this message | ||
hi,
i've run in to a strange problem,
i'm trying to output a pdf file from disk to the browser.
this is fine under netscape but IE has problems.
consider the following code:
-------------------------------------------
<?
error_reporting(E_ALL);
session_start();
if (!isset($_SESSION['download'])) {
@$_SESSION['download'] = $_GET['download'];} if(isset($_GET["download"])){ $file_name=$_SESSION['download']; header("Content-type:application/pdf"); header("Content-Disposition: inline;filename=\"mypdf.pdf\""); header("Content-length:".(string)(filesize($file_name))); header("location: $file_name"); exit; } ?> <form method=get> <INPUT TYPE="submit" name=download value="mypdf.pdf"> </form> ------------------------------------------ the above code runs fine on NS and IE, IE immediately loads and opens the pdf file inline. but this code which only has the difference of using the POST method instead of the GET metod results in a "file is corrupt" message! ------------------------------------------ <? error_reporting(E_ALL); session_start(); if (!isset($_SESSION['download'])) {
@$_SESSION['download'] = $_POST['download'];} if(isset($_POST["download"])){ $file_name=$_SESSION['download']; header("Content-type:application/pdf"); header("Content-Disposition: inline;filename=\"mypdf.pdf\""); header("Content-length:".(string)(filesize($file_name))); header("location: $file_name"); exit; } ?> <form method=post> <INPUT TYPE="submit" name=download value="mypdf.pdf"> </form> ------------------------------------------ can anyone explain to me why you can't use the POST method? is this a bug or is this as expected (i didn't). tnx, gilles i'm running php 4.2.1 on win2000 with IIS5