note 25084 deleted from function.fpassthru by vincent
| From: | vincent@php.net | Date: | Sat, 16 Aug 2003 21:17:34 +0000 |
| Subject: | note 25084 deleted from function.fpassthru by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54480@lists.php.net to get a copy of this message | ||
Note Submitter:
----
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;
?>