#36905 [Opn]: PUT returns no data via php://stdin
| From: | bjori@php.net | Date: | Wed, 29 Mar 2006 12:54:04 +0000 |
| Subject: | #36905 [Opn]: PUT returns no data via php://stdin | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-95073@lists.php.net to get a copy of this message | ||
ID: 36905
Updated by: bjori@php.net
Reported By: dbarrett at quinthar dot com
Status: Open
Bug Type: HTTP related
Operating System: Linux Fedora Core 3
PHP Version: 4.4.2
New Comment:
STDIN/php://stdin is only set in php-cli, use php://input
..and read the warnings on http://php.net/manual/en/function.fread.php
Previous Comments:
------------------------------------------------------------------------
[2006-03-29 07:59:57] dbarrett at quinthar dot com
Description:
------------
Reading from 'php://stdin' should produce the contents of the file
uploaded via PUT, but nothing actually comes out. This is the same
issue as described in bug #10383 (and marked as bogus), though it is
anything but.
Reproduce code:
---------------
<?php
$filename = "myputfile.ext";
$totalWritten = 0;
$inFP = fopen( "php://stdin", "rb" );
$outFP = fopen( $filename, "wb" );
fwrite( $outFP, "testing 1, 2, 3" );
while( $data = fread( $inFP, 1024 ) )
{
fwrite( $outFP, $data );
$totalWritten += strlen( $data );
}
fclose($inFP);
fclose($outFP);
if( $totalWritten ) header( "HTTP/1.0 200 Success ($filename)"
);
else header( "HTTP/1.0 404 Failed ($filename)"
);
?>
Expected result:
----------------
I expected the test file to successfully upload, and the script to
return 200 Success.
Actual result:
--------------
In actuality, the file does not upload. Rather, though it's able to
open and write the test string to the file, it does not write any of
the file contents itself. The actual command output follows:
-------------- Client Side ------------------
D:\>type test
Hello world!
D:\>curl -i -T test http://www.XXXX.com/
HTTP/1.1 100 Continue
HTTP/1.1 404 Failed (myputfile.ext)
Date: Wed, 29 Mar 2006 07:17:03 GMT
Server: Apache
X-Powered-By: PHP/5.0.5
Content-Length: 1
Content-Type: text/html
-------------- Server Side ------------------
[root@www www.XXXX.com]# cat myputfile.ext
testing 1, 2, 3[root@www www.XXXX.com]#
I've confirmed this identical behavior using both 'curl' and 'libcurl',
on two different versions of Linux/Apache/PHP.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36905&edit=1