note 71082 added to function.fpassthru
| From: | simonatparagi dot dk at osu1 dot php dot net | Date: | Sat, 11 Nov 2006 02:23:46 +0000 |
| Subject: | note 71082 added to function.fpassthru | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119600@lists.php.net to get a copy of this message | ||
This code is usefull to controle access to files other then HTML, that the browser know how to show.
<?php
// Find mime type
if(function_exists('mime_content_type'))
$content_type=mime_content_type($file_name);
else
$content_type=trim(exec('file -bi '.escapeshellarg($file_name)));
// Send header
header('Content-Type: '.$content_type);
// Pass file
$fp = fopen($file_name, 'rb');
fpassthru($fp);
fclose($fp);
?>
Simon at http://paragi.com
----
Server IP: 195.184.96.15
Probable Submitter: 212.242.117.72
----
Manual Page -- http://www.php.net/manual/en/function.fpassthru.php
Edit -- https://master.php.net/note/edit/71082
Del: integrated -- https://master.php.net/note/delete/71082/integrated
Del: useless -- https://master.php.net/note/delete/71082/useless
Del: bad code -- https://master.php.net/note/delete/71082/bad+code
Del: spam -- https://master.php.net/note/delete/71082/spam
Del: non-english -- https://master.php.net/note/delete/71082/non-english
Del: in docs -- https://master.php.net/note/delete/71082/in+docs
Del: other reasons-- https://master.php.net/note/delete/71082
Reject -- https://master.php.net/note/reject/71082
Search -- https://master.php.net/manage/user-notes.php