note 58522 added to function.mail

From: Date: Mon, 07 Nov 2005 11:53:48 +0000
Subject: note 58522 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-98187@lists.php.net to get a copy of this message
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 } } } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.mail.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58522 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58522&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58522&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58522&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58522&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58522&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58522&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58522&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58522&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98187) next »