For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > March 2006 > #36905 [Ver->Csd]: PUT returns no data via php://stdin









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #36905 [Ver->Csd]: PUT returns no data via php://stdin
simp@php.net

2006-03-29, 9:57 pm

ID: 36905
Updated by: simp@php.net
Reported By: dbarrett at quinthar dot com
-Status: Verified
+Status: Closed
Bug Type: Documentation problem
Operating System: *
PHP Version: 4.4.2
Assigned To: simp
New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.




Previous Comments:
------------------------------------------------------------------------

[2006-03-29 22:49:55] bjori@php.net

Re-opend as documentation problem.
That page needs makeover.

------------------------------------------------------------------------

[2006-03-29 21:17:33] dbarrett at quinthar dot com

Switching from "php://stdin" to "php://input" worked great, thanks!
Should the documentation be updated to reflect this? The 'Put Method
Support' documentation seems simply incorrect in light of this:

http://us3.php.net/manual/en/featur....put-method.php

------------------------------------------------------------------------

[2006-03-29 14:54:26] bjori@php.net

..

------------------------------------------------------------------------

[2006-03-29 14:54:03] bjori@php.net

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

------------------------------------------------------------------------

[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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com