homer.favenir Posted September 25, 2009 Share Posted September 25, 2009 hi, i have a script that views a pdf in a browser, namely mozilla. instead it prompt me to download the php file. <?php session_start(); if(!isset($_SESSION['userid'])) die($_SESSION['userid']); ob_start(); $book = $_GET['book']; $fileExtension = "pdf"; $sourceFile = "\\\\asecasiagsd\\ags\\ags\\wip\\upload\\".$book; $outputFile = $sourceFile; // the name they save as can be different to the existing file // required for IE, otherwise Content-disposition is ignored //if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); switch( $fileExtension) { case "pdf": $ctype="application/pdf"; break; case "exe": $ctype="application/octet-stream"; break; case "zip": $ctype="application/zip"; break; case "doc": $ctype="application/msword"; break; case "xls": $ctype="application/vnd.ms-excel"; break; case "ppt": $ctype="application/vnd.ms-powerpoint"; break; case "gif": $ctype="image/gif"; break; case "png": $ctype="image/png"; break; case "jpeg": case "jpg": $ctype="image/jpg"; break; default: $ctype="application/force-download"; } //session_cache_limiter(""); 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-Type: $ctype"); //header("Content-Disposition: attachment; filename=".basename($outputFile).";" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($sourceFile)); readfile("$outputFile") ; // This is the bit that prompts for the download, supress errors for niceness exit(); ?> Link to comment https://forums.phpfreaks.com/topic/175459-view-pdf-in-mozilla/ Share on other sites More sharing options...
khr2003 Posted September 25, 2009 Share Posted September 25, 2009 why this line is commented: //header("Content-Disposition: attachment; filename=".basename($outputFile).";" ); Link to comment https://forums.phpfreaks.com/topic/175459-view-pdf-in-mozilla/#findComment-924727 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.