php://input - what does it do in fopen()?

laukok picture laukok · Aug 16, 2011 · Viewed 12.3k times · Source
$handle = fopen("/home/rasmus/file.txt", "r");
$handle = fopen("/home/rasmus/file.gif", "wb");

I can understand this that /home/rasmus/file.txt and /home/rasmus/file.gif are the file path.

But what these mean:

php://input
php://temp

in

$objInputStream = fopen("php://input", "r");
$objTempStream = fopen("php://temp", "w+b");

What do they do?

Answer

adritha84 picture adritha84 · Aug 16, 2011

php://input is a read-only stream that allows you to read raw data from the request body. In the case of POST requests, it is preferable to $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives. Moreover, for those cases where $HTTP_RAW_POST_DATAis not populated by default, it is a potentially less memory intensive alternative to activating always_populate_raw_post_data. php://input is not available with enctype="multipart/form-data".

Check out the manual: http://php.net/manual/en/wrappers.php.php