note 58522 deleted from function.mail by jome

From: Date: Mon, 07 Nov 2005 14:34:25 +0000
Subject: note 58522 deleted from function.mail by jome
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-98192@lists.php.net to get a copy of this message
Note Submitter: php dot net at stephen-scotter dot net Reason: useless ---- For anyone struggling to force the download of PDFs, I've found this very helpful! <?php // pdfdownload.php // version 1.0 // www.pdfhacks.com/serving_pdf/ // // WARNING: // This script might compromise your server's security. $fn= $_GET['fn']; // as a security measure, only serve files located in our directory if( $fn && $fn=== basename($fn) ) { // make sure we're serving a PDF (and not some system file) if( strtolower( strrchr( $fn, '.' ) )== '.pdf' ) { if( ($num_bytes= @filesize( $fn )) ) { // use file pointers instead of readfile() // for better performance, esp. with large PDFs if( ($fp= @fopen( $fn, 'rb' )) ) { // open binary read success // try to conceal our content type header('Content-Type: application/octet-stream'); // cue the client that this shouldn't be displayed inline header('Content-Disposition: attachment; filename='.$fn); // we don't support byte serving header('Accept-Ranges: none'); header('Content-Length: '.$num_bytes); fpassthru( $fp ); // this closes $fp } } } } ?>

« previous php.notes (#98192) next »