note 25084 added to function.fpassthru
| From: | php-general at lists dot php dot net | Date: | Tue, 10 Sep 2002 09:28:41 +0000 |
| Subject: | note 25084 added to function.fpassthru | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36432@lists.php.net to get a copy of this message | ||
Don't mix this function with passthru() which executes an external command and pipes its output
to the standard output, like the
backtick, except that the result is not returned in a
string.
fpassthru() is generally not restricted in safe_mode (provided that you have access to the
referenced file), and it is great for example when a script must return an image from a collection.
Note however that before using fpassthru() to return an image or binary file or downloaded file, you
should explicitly set its content-type to something else than the default text/html. And don't
forget to use "exit;" to avoid adding garbage characters or newlines after the passed
through file (for example superfluous CRLF that may be present at end of your present script after
the ?> tag). For example:
<?php
$name = "foobar.gif";
header("Content-Type: image/gif");
header("Content-Length: ".filesize($name));
fpassthru($name);
exit;
?>
--
http://www.php.net/manual/en/function.fpassthru.php
http://master.php.net/manage/user-notes.php?action=edit+25084
http://master.php.net/manage/user-notes.php?action=delete+25084
http://master.php.net/manage/user-notes.php?action=reject+25084